fix(env): treat empty-string env vars as unset across all apps#8
Merged
Conversation
Railway/Nixpacks (and several other PaaS / CI runners) pass unset env vars to Node as "" rather than omitting them. That made every Railway boot since PR #3 crash with: Invalid environment: ZodError: NODE_ENV — Expected 'development' | 'production' | 'test', received '' The new validation introduced in #3 is correct in spirit (fail loud on bad config) but `.optional()` on enum/url/coerce.number rejects "" — exactly the value Railway ships in practice. Wrap each app's schema in a `z.preprocess` step that maps "" → undefined before the typed schema runs. Add regression tests covering NODE_ENV, LOG_LEVEL, PUBLIC_URL, and PORT under empty-string input. Also stage the apps/web/.gitignore update from `vercel link` so the generated .vercel/ directory stays out of the repo.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Follow-up to #3. Railway/Nixpacks (and several other PaaS / CI runners) pass unset env vars to Node as
""rather than omitting them. The strict env validation introduced in #3 rejected""because.optional()onenum/url/coerce.numberonly acceptsundefined. Result: every Railway boot since #6 merged crashed with:Fix
Wrap each app's schema in
z.preprocessthat maps""→undefinedbefore the typed schema runs. Same pattern across all three apps so behaviour is consistent.Tests
Added 4 regression tests in
apps/api/schemas.test.tscoveringNODE_ENV,LOG_LEVEL,PUBLIC_URL, andPORTunder empty-string input. 162/162 tests pass locally.Notes
.gitignoreupdate fromvercel link(excludesapps/web/.vercel/)Test plan
curl https://pagent.up.railway.app/health→{"ok":true,"db":"ok"}