Skip to content

Add startup configuration validation gate#1608

Merged
kryputh merged 2 commits into
Stellar-Mail:mainfrom
Esc1200:fix/1516-config-validation-gate
Jul 20, 2026
Merged

Add startup configuration validation gate#1608
kryputh merged 2 commits into
Stellar-Mail:mainfrom
Esc1200:fix/1516-config-validation-gate

Conversation

@Esc1200

@Esc1200 Esc1200 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Goal

Validate required environment bindings, secrets, supported versions, and storage adapters at startup / first initialization so misconfigured deployments fail clearly before serving partial or unsafe API behavior (issue #1516).

Changes

  • src/server/api/context.ts: extract validateApiConfig() — enforces KV + coordinator bindings, the cursor secret, and at least one supported version in production; distinguishes dev vs prod; never logs secret values. getApiContext() calls it before constructing the production repository.
  • tests/unit/api/config-validation.test.ts: valid dev, valid prod, missing KV/coordinator/secret in prod, no secret leakage in error messages, empty supported-versions, and dev bypass.

Verification

  • npx vitest run tests/unit/api/config-validation.test.ts → 8 passed.
  • npx prettier@3.8.5 --check clean on changed files.

Fixes #1516

Esc1200 added 2 commits July 20, 2026 04:50
- Read STEALTH_CURSOR_SECRET via a defensive cast (not declared on the
  Cloudflare env type) so an undeclared secret fails the validation gate
  instead of a type error.
- Restore the KV/coordinator presence guard so HybridApiRepository receives
  non-undefined bindings (narrows KVNamespace | undefined).
@kryputh
kryputh merged commit 04e3160 into Stellar-Mail:main Jul 20, 2026
5 checks passed
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.

Add a startup configuration validation endpoint-safe gate

2 participants