fix(config): treat every blank template key as unset - #338
Open
CARLOSNAMIAS wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
What changes
Eleven optional environment keys that
.env.examplepublishes blank move fromz.string().optional()to theOptionalNonEmptyhelper already defined inconfig.ts. Ten of them currently reach the config object as""instead of unset:Three test cases are added that pair the published template with the schema that has
to accept it.
Why
pnpm devcopies.env.exampleverbatim apart from the two secrets it generates, soevery blank key reaches
readConfigexactly as shipped. Nothing breaks today — everyconsumer happens to test truthiness (
github/client.ts:56,story-domain.ts:56,worker.ts:21) — but this is the same defect class that made the API refuse to bootfrom a copied
.env.examplein #158 and #183, and it fails the moment a consumerreaches for
??or!== undefined. TheOptionalNonEmptyhelper exists for exactlythis, with a comment saying so; it just was not applied to these keys.
Nothing covered the template/schema pair before:
config.test.tsbuilds its ownenvironment objects and
scripts/dev.test.mjswrites its own template, so the twofiles could drift again without a failing test. The invariant the third case fixes —
no config field is an empty string on a first run — holds for keys added to the
template later, not just today's.
Related: #158, #183.
Verification
pnpm verifypasses locallyI could not run
pnpm verify: I am on Windows 11 (Node 24.12.0, pnpm 11.20.0) withoutthe local PostgreSQL and Docker stack, and the Docker and Vercel tiers need a Unix shell
on the host. Rather than claim a green suite I did not produce, here is exactly what I
ran and what it proved:
pnpm --filter @facility/api exec vitest run test/config.test.tsservices/api/src/config.tsrevertedpnpm --filter @facility/api exec vitest runpnpm --filter @facility/api typecheckThe 14 failures are the Docker and Vercel tiers (
spawn sh ENOENT,sudo: unexpected argument '-u'), identical with and without this change. I did not runpnpm test:e2e-workspaceor the database integration suites, and I did not exercise therunning application in a browser — this change has no UI surface.
pnpm exec biome check services/apireports 100 errors on my machine and the same 100 onan unmodified tree: a CRLF working tree on Windows, not this change. The committed content
is LF.