fix: strip quoted env var values before Zod validation#484
Closed
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Closed
fix: strip quoted env var values before Zod validation#484devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
Infisical export and some .env loaders produce values wrapped in single quotes (e.g. NEXT_PUBLIC_SUPPORT_EMAIL='support@codebuff.com'), causing Zod format validators (z.email(), z.url()) to reject them. - Add stripEnvQuotes() to common/src/env-schema.ts so clientProcessEnv values are sanitised before schema validation runs - Add the same stripping logic to sdk/test/setup-env.ts preload so test environment values are also cleaned up early Co-Authored-By: James <james@codebuff.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Infisical export (and some
.envloaders) can produce env var values wrapped in literal single quotes, e.g.:This sets the value to the string
'support@codebuff.com'(quotes included), which fails Zod v4'sz.email()andz.url()validators at module load time incommon/src/env.ts, crashing all downstream imports (SDK, agents, etc.) before any test code runs.Fix: Add a
stripEnvQuotes()function in two places:common/src/env-schema.ts— wraps eachprocess.env.*read inclientProcessEnvso quoted values are sanitized before schema validation. This runs in all environments.sdk/test/setup-env.ts— strips quotes from existing env vars before setting test defaults. This runs only via the test preload.Review & Testing Checklist for Human
clientProcessEnvcomment notes Bun statically replacesprocess.env.NEXT_PUBLIC_*references. Verify that wrapping them instripEnvQuotes(process.env.NEXT_PUBLIC_*)doesn't break Bun's compile-time substitution (e.g. innext buildorbun build).Notes
stripEnvQuoteslogic is duplicated across the two files with slightly different signatures (one returns a value, the other mutatesprocess.envin place). Could be extracted to a shared util if preferred, but kept separate to minimize import surface.Link to Devin session: https://app.devin.ai/sessions/703473308c2c41e2a915b61e6c597c30