Skip to content

Implement readiness checks for required API dependencies#1581

Open
Chigybillionz wants to merge 6 commits into
Stellar-Mail:mainfrom
Chigybillionz:readiness-cjeck
Open

Implement readiness checks for required API dependencies#1581
Chigybillionz wants to merge 6 commits into
Stellar-Mail:mainfrom
Chigybillionz:readiness-cjeck

Conversation

@Chigybillionz

Copy link
Copy Markdown

Closes #1515

Summary of the issue

The API exposed a health endpoint, but it only reported that the process could respond. A live process could still be unable to serve traffic if required API dependencies such as storage or Cloudflare bindings were missing or unavailable.

Root cause

GET /api/v1/health returned a static success payload and did not define separate liveness and readiness semantics. It also did not probe required production dependencies, enforce bounded dependency check timeouts, or guarantee sanitized readiness output.

Solution implemented

Separated liveness from readiness within the existing health route:

  • GET /api/v1/health remains a liveness check and does not depend on external systems.
  • GET /api/v1/health?check=readiness performs required dependency readiness checks.
  • Readiness checks are bounded by timeouts.
  • Readiness responses expose only safe dependency statuses and do not leak binding names, connection details, secrets, or internal error messages.

Key changes made

  • Added checkApiReadiness helper for testable readiness checks.
  • Added checks for required API bindings/context, storage access, and coordinator access.
  • Updated the health route to return 503 when readiness fails.
  • Added unit coverage for successful readiness, missing bindings, unavailable storage, timeout behavior, and sanitized output.
  • Documented the liveness/readiness contract in API docs and OpenAPI metadata.

Trade-offs or considerations

The readiness check uses lightweight read-only probes so it can verify dependency availability without mutating production data. Dependency failures are intentionally sanitized, so operators get a clear component-level status without exposing internal configuration or connection details.

Testing steps

  1. Run unit tests:

    npm test -- tests/unit/api/health.test.ts

  1. Verify liveness returns 200 without dependency probing:
    curl -i http://localhost:8080/api/v1/health
  2. Verify readiness returns 200 when required dependencies are available:
    curl -i "http://localhost:8080/api/v1/health?check=readiness"
  3. Verify readiness returns 503 with sanitized dependency statuses when required storage or bindings are unavailable.

Please kindly review this task. If there are any corrections, improvements, adjustments, or merge conflicts that you notice regarding my implementation, I'd really appreciate your feedback. I'd also love to hear your overall review of my work on this branch.Thank you!

@kryputh

kryputh commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

@Chigybillionz fix conflict

@Chigybillionz

Chigybillionz commented Jul 20, 2026 via email

Copy link
Copy Markdown
Author

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.

Implement readiness checks for required API dependencies

2 participants