fix(api): treat empty optional env vars as unset - #159
Open
stringbitking wants to merge 1 commit into
Open
Conversation
.env.example ships VERCEL_TOKEN=, VERCEL_OIDC_TOKEN=, VERCEL_TEAM_ID= and VERCEL_PROJECT_ID= as blank assignments, and pnpm dev copies them verbatim into .env. dotenv delivers a blank assignment as an empty string, which the min(1).optional() declarations reject — so a fresh clone's first boot crashes the API and the worker while the rest of the stack comes up. Extend the file's existing blank-to-undefined preprocess idiom (already used by OptionalUrl, OptionalGithubOrganization and FACILITY_PREVIEW_SURFACE_TOKEN) to the whole optional non-empty group: VERCEL_*, FACILITY_AWS_CODEBUILD_* and PACKAGE_REGISTRY_TOKEN. A blank or whitespace-only value now parses as unset, matching how facility doctor already reasons about these values; a value that is actually set must still be non-empty. Fixes theam#158 Co-Authored-By: Claude Fable 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.
Fixes #158 — a fresh clone's
pnpm devcrashes the API and worker because.env.exampleships theVERCEL_*keys as blank assignments (KEY=), dotenv delivers those as empty strings, and themin(1).optional()declarations inservices/api/src/config.tsreject empty-present values.What this does
Implements Option A from the issue: extends the blank-to-undefined preprocess idiom the file already uses for
OptionalUrl,OptionalGithubOrganization, andFACILITY_PREVIEW_SURFACE_TOKENto the whole optional non-empty group —VERCEL_TOKEN,VERCEL_OIDC_TOKEN,VERCEL_TEAM_ID,VERCEL_PROJECT_ID,FACILITY_AWS_CODEBUILD_PROJECT,FACILITY_AWS_CODEBUILD_CACHE_BASE_LOCATION, andPACKAGE_REGISTRY_TOKEN.A blank or whitespace-only value now parses as unset (matching how
facility doctoralready reasons about these values via truthiness), while a value that is actually set must still be non-empty after trimming. Existing generated.envfiles heal without edits.Why this doesn't change an intentional guarantee
FACILITY_SANDBOX_DRIVER=vercel— absent tokens already boot fine today, so the currentmin(1)only rejected one spelling of "not configured" while accepting the other.facility doctorremains the fail-fast surface for "driver selected but not configured".Happy to rework toward Option B (comment the blank lines out of
.env.example, keep the strict schema) if you prefer strict-presence semantics.Tests
Two new cases in
services/api/test/config.test.ts:.env-template shape (all seven keys blank) boots and resolves every value toundefined;vitest run test/config.test.ts: 16 passed.tsc --noEmitandbiome checkclean on the touched files.🤖 Generated with Claude Code