Skip to content

feat(api-keys): validate outbound API keys at startup and before each…#3

Open
fricigliano wants to merge 1 commit into
mainfrom
feat/api-key-health-preflight
Open

feat(api-keys): validate outbound API keys at startup and before each…#3
fricigliano wants to merge 1 commit into
mainfrom
feat/api-key-health-preflight

Conversation

@fricigliano

Copy link
Copy Markdown
Collaborator

… run

Add active validation of the keys the pipeline uses to call external services (OpenAI, Bigdata.com), so a revoked/mistyped key surfaces as a clear, actionable error instead of failing deep inside a long run.

  • key_health.py: probe OpenAI (models.list, no tokens) and Bigdata (light authenticated KG call). Distinguish rejected (401/403) from unreachable; TTL-cached so a large batch probes upstream at most once per minute.
  • Startup: log one line per key in the FastAPI lifespan (non-blocking).
  • GET /health/keys: cached per-key status, 503 if any key is rejected. Kept separate from /health (liveness must not depend on upstreams).
  • Preflight before fan-out: batch_run_parallel and start_scan raise a 503 with the offending key; stateless MCP start_briefs_run returns ERROR.
  • Stateful MCP _api now surfaces the server's detail so the client sees the real reason instead of a bare "503 Server Error".

… run

Add active validation of the keys the pipeline uses to call external
services (OpenAI, Bigdata.com), so a revoked/mistyped key surfaces as a
clear, actionable error instead of failing deep inside a long run.

- key_health.py: probe OpenAI (models.list, no tokens) and Bigdata (light
  authenticated KG call). Distinguish rejected (401/403) from unreachable;
  TTL-cached so a large batch probes upstream at most once per minute.
- Startup: log one line per key in the FastAPI lifespan (non-blocking).
- GET /health/keys: cached per-key status, 503 if any key is rejected.
  Kept separate from /health (liveness must not depend on upstreams).
- Preflight before fan-out: batch_run_parallel and start_scan raise a 503
  with the offending key; stateless MCP start_briefs_run returns ERROR.
- Stateful MCP _api now surfaces the server's `detail` so the client sees
  the real reason instead of a bare "503 Server Error".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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