fix(dashboard_api): jsonable_encoder on /health/ingest (datetime serialize)
Some checks are pending
Static Analysis / static (push) Waiting to run
Tests / test (push) Waiting to run
Static Analysis / static (pull_request) Waiting to run
Tests / test (pull_request) Waiting to run

The ingest-health handler returned reporting.v_ingest_health rows straight to
JSONResponse, but last_run_at is a datetime — json.dumps raised TypeError and the
endpoint fell into its except, always returning {"overall":"unknown","endpoints":[]}.
Every other analytics endpoint already routes through jsonable_encoder; this one
didn't. Surfaced when the prod bridge finally got the /health/ingest route.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
david kiania 2026-07-02 23:57:32 +03:00
parent b11294009b
commit 621a30cd81

View file

@ -205,7 +205,10 @@ def ingest_health():
else "stale" if any(r["freshness"] == "stale" for r in rows) else "stale" if any(r["freshness"] == "stale" for r in rows)
else "ok" else "ok"
) if rows else "unknown" ) if rows else "unknown"
return JSONResponse({"overall": worst, "endpoints": rows}) # rows carry last_run_at (datetime) — jsonable_encoder (Decimal→float,
# datetime→ISO) before JSONResponse, else json.dumps raises TypeError
# and the whole feed 500s into the except below. (260702 fix.)
return JSONResponse(jsonable_encoder({"overall": worst, "endpoints": rows}))
except Exception: except Exception:
log.exception("ingest-health failed") log.exception("ingest-health failed")
return JSONResponse( return JSONResponse(