Document missing env vars and add a CI check for the invariant - #173
Open
Otfrugger wants to merge 1 commit into
Open
Document missing env vars and add a CI check for the invariant#173Otfrugger wants to merge 1 commit into
Otfrugger wants to merge 1 commit into
Conversation
…iant Add commented KEY=default entries to .env.example for every process.env read under apps/api/src that had no matching line in an example file: RATE_LIMIT_STRICT_WINDOW_MS/MAX, TRUST_PROXY_HOPS, REDIS_URL, DEFAULT_SELLER_WALLET, DEFAULT_SELLER_NAME, WEBHOOK_HOST_ALLOWLIST, ANCHOR_PROBE_FAILURE_THRESHOLD/COOLDOWN_MS, WATCHER_CONCURRENCY, WATCHER_MAX_ACCOUNTS_PER_TICK, WATCHER_CIRCUIT_BREAKER_THRESHOLD/COOLDOWN_MS, WATCHER_IDLE_BACKOFF_TICKS, WATCHER_AGGRESSIVE_POLL_TICKS, SHUTDOWN_TIMEOUT_MS. TRUST_PROXY_HOPS carries the blank-value footgun warning from docs/MAINNET.md. Add scripts/check-env-docs.mjs, mirroring check-domain-boundary.mjs: it scans apps/api/src for process.env.X reads and fails if X (outside an explicit NODE_ENV/RENDER_EXTERNAL_HOSTNAME exemption for platform-injected vars) isn't documented in .env.example or .env.public.example. Wired into CI via a new docs:check-env-docs script.
|
@Otfrugger Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@Otfrugger is attempting to deploy a commit to the determined's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
closes #164
Summary
The issue's premise was that
apps/api/src/env.tsis the single reader of process configuration. That's no longer true — greppingapps/api/srcforprocess.env.(excludingenv.tsitself) turned up six more files reading env vars directly:routes/telemetry.ts,routes/webhooks.ts,services/webhook-sender.ts,services/container.ts,services/secret-crypto.ts,services/ssrf-guard.ts. Most of those reads (TELEMETRY_TOKEN,WEBHOOK_SECRET_ENCRYPTION_KEY,NODE_ENV) were already fine or already documented, but three were not:WEBHOOK_HOST_ALLOWLIST,ANCHOR_PROBE_FAILURE_THRESHOLD,ANCHOR_PROBE_COOLDOWN_MS. I've scoped the fix (and the new check) to all ofapps/api/src, not justenv.ts, so this doesn't just recreate the same gap for those files..env.exampleadditions (commented, with default + one-line effect)RATE_LIMIT_STRICT_WINDOW_MS/RATE_LIMIT_STRICT_MAXTRUST_PROXY_HOPS— carries the exact blank-value footgun warning fromdocs/MAINNET.md(TRUST_PROXY_HOPS=parses to0, silently collapsing every client into one rate-limit bucket)REDIS_URL,DEFAULT_SELLER_WALLET(previously prose-only, now a real line),DEFAULT_SELLER_NAMEWEBHOOK_HOST_ALLOWLIST,ANCHOR_PROBE_FAILURE_THRESHOLD,ANCHOR_PROBE_COOLDOWN_MSWATCHER_CONCURRENCY,WATCHER_MAX_ACCOUNTS_PER_TICK,WATCHER_CIRCUIT_BREAKER_THRESHOLD,WATCHER_CIRCUIT_BREAKER_COOLDOWN_MS,WATCHER_IDLE_BACKOFF_TICKS,WATCHER_AGGRESSIVE_POLL_TICKS(noted as currently unused by the watcher loop —isNewAccountbypasses backoff entirely instead of consulting this var)SHUTDOWN_TIMEOUT_MSNone of these need a
.env.public.exampleentry: per that file's own header ("lists only what differs from.env.example, plus everything the guardrails make mandatory"),TRUST_PROXY_HOPS,DEFAULT_SELLER_WALLETandREDIS_URLare already there, and the rest don't have mainnet-specific defaults.CI check
Added
scripts/check-env-docs.mjs, mirroring the existingscripts/check-domain-boundary.mjspattern (dependency-free.mjs, regex scan,process.exit(1)with actionable output). It scansapps/api/srcforprocess.env.Xreads and fails ifXhas no matchingX=line in.env.exampleor.env.public.example, with an explicit exemption list (currentlyNODE_ENV,RENDER_EXTERNAL_HOSTNAME— both platform-injected, not operator-set). Wired intopackage.jsonasdocs:check-env-docsand into.github/workflows/ci.ymlalongside the otherdocs:check-*steps.Verification
node scripts/check-env-docs.mjsdirectly (Node is available in this environment; pnpm/turbo/vitest are not) — passes clean against the updated.env.example.pnpm typecheck,pnpm test, or the fullpnpm docs:check-env-docsvia the turbo/pnpm pipeline, since no pnpm/turbo install is available here. Please run those before merging — the standalonenode scripts/check-env-docs.mjsinvocation above is the only local verification I could do.Caveats
WATCHER_AGGRESSIVE_POLL_TICKSis documented honestly as unused dead config rather than inventing behavior for it; may be worth a separate follow-up to either wire it up or remove it.