Add startup configuration validation gate#1608
Merged
kryputh merged 2 commits intoJul 20, 2026
Merged
Conversation
- 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: extractvalidateApiConfig()— 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 --checkclean on changed files.Fixes #1516