[eas-cli] Quote env:pull values dotenv cannot read back verbatim - #4240
Open
dennytosp wants to merge 1 commit into
Open
[eas-cli] Quote env:pull values dotenv cannot read back verbatim#4240dennytosp wants to merge 1 commit into
dennytosp wants to merge 1 commit into
Conversation
|
Subscribed to pull request
Generated by CodeMention Warning: The preamble and epilogue options in commentConfiguration are deprecated. Use template instead. |
dennytosp
force-pushed
the
fix/env-pull-quote-values
branch
from
August 21, 2026 06:43
3e0465a to
096f93b
Compare
dennytosp
force-pushed
the
fix/env-pull-quote-values
branch
from
September 3, 2026 10:31
e614323 to
949ac3a
Compare
dotenv trims unquoted values, cuts them at the first `#`, and strips one layer of quotes, so `eas env:pull` silently truncated any value with a comment marker (a hex color, a URL fragment) and dropped values with newlines or surrounding whitespace. Move the quoting helper the integrations code already had into `utils/dotenv.ts`, extend it to pick a quote style the value can actually survive, and use it for every line `env:pull` writes. Fixes expo#2813
dennytosp
force-pushed
the
fix/env-pull-quote-values
branch
from
September 5, 2026 20:06
949ac3a to
9365881
Compare
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.
Why
Fixes #2813.
eas env:pullwrites every value straight into the.envfile without quoting, butdotenvdoes not read every string back the way it was written. It trims unquoted values, cuts them at the first#, and strips one layer of surrounding quotes. So a variable holding a hex colour, a URL with a fragment, or any value with a comment marker is silently truncated:The same applies to values with surrounding whitespace or newlines (an RSA key, for example), which are dropped or split across lines.
How
packages/eas-cli/src/integrations/shared/envFile.tsalready carried a privateformatEnvValuefor exactly this problem, so rather than adding a second copy of the same dotenv trivia this moves it tosrc/utils/dotenv.tsand uses it for every lineenv:pullwrites.While sharing it, it also grew two cases the original could not represent, both reachable from real values:
"cannot be double quoted, because dotenv strips the outer pair but never unescapes\". JSON values were only surviving by accident, and a JSON value that also contains a#was being cut in half. These now use single quotes (or backticks), which dotenv reads verbatim.\ntwo-character sequence cannot be double quoted either, since dotenv turns that back into a real newline. It is quoted the same way.Plain values are still written unquoted, so existing
.env.localfiles do not churn.Test Plan
packages/eas-cli/src/utils/__tests__/dotenv-test.tsround-trips values through the realdotenv.parse, so the assertions are about what dotenv actually does rather than about the string shape: hex colours, URL fragments, surrounding whitespace, every quote character, literal escape sequences, JSON, and a multi-line private key. It also asserts a value cannot smuggle in a second key definition.EnvPull.test.tsgets a variable holding#99ccffand asserts the written file parses back to#99ccff.yarn typecheck,yarn lint(0 warnings), andyarn fmt:checkare clean.