Skip to content

feat(api): error surface — deep health preflights + error_id handler - #75

Merged
rrskris merged 1 commit into
mainfrom
feat/error-surface
Jul 18, 2026
Merged

rrskris merged 1 commit into
mainfrom
feat/error-surface

Conversation

@rrskris

@rrskris rrskris commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

What

Written tests-first (tests/test_error_surfacing.py, 10 tests): Postgres down, CVE feeds missing/never-refreshed/stale, kubeconfig absent, unauthenticated request, unhandled server exception. Bad --manifests paths were already pinned by test_cli_manifests_errors.py (#45).

  • GET /health?deep=1 (new app/health.py): preflights Postgres, CVE feed presence + freshness (48h staleness window = two missed scheduler cycles), and Kubernetes credentials. Every failing check carries the exact fix: the compose one-liner for Postgres, POST /cve/feeds/refresh-all for stale feeds, KUBECONFIG/ServiceAccount guidance (pointing at deploy/cronjob.yaml) for cluster access. 503 only when a required dependency is down; optional failures report degraded. Plain GET /health stays a dependency-free liveness probe.
  • Global exception handler: full traceback logged under a generated error_id; the client receives only {"detail", "error_id"} — never the stack, exception type, or message. DB URLs render with the password masked everywhere.

Verification

  • Full suite: 65 passed locally against real Postgres.
  • Live boot + curl: /health?deep=1 returns degraded with per-check fixes when feeds are unrefreshed and no kubeconfig is present; credentials masked (kaaval:***@); shallow probe 200.

Tests first (tests/test_error_surfacing.py): Postgres down, CVE feed
missing/never-refreshed/stale, kubeconfig absent, unauthenticated
request, and unhandled server exception.

GET /health stays a cheap liveness probe; /health?deep=1 preflights
every dependency and reports each failure with the exact fix command
(compose one-liner for Postgres, /cve/feeds/refresh-all for stale
feeds, KUBECONFIG/ServiceAccount guidance for cluster access). 503
only when a required dependency is down; optional failures degrade.

Global exception handler logs the full traceback under a generated
error_id and returns only that id to the client — stack traces,
exception types, and messages never leave the server. Connection URLs
are rendered with the password masked everywhere.

Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
@rrskris
rrskris enabled auto-merge (squash) July 18, 2026 14:22
@rrskris
rrskris merged commit cd94e45 into main Jul 18, 2026
5 checks passed
rrskris added a commit that referenced this pull request Aug 5, 2026
@floze-the-genius shipped three PRs, but only the bugfix (#100) appeared in the
changelog — the two features it built on, GET /rbac/scan/diff (#82) and the
kaaval doctor preflight (#80), were missing entirely. Anyone reading the release
notes would see the fix to a feature whose arrival was never recorded.

Scope of each entry was taken from the merge commits rather than the issue
titles: #80 adds the CLI command and typed health results on top of the deep
health checks that #75 already provided, so it is credited for the wrapper it
actually wrote, not for the checks themselves.

Prep for the v1.2.0 release notes, so the credit ships in the release rather
than as a later correction.

Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant