Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): don't interpolate env variables with undefined value #8013

Merged
merged 1 commit into from Sep 3, 2020

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Sep 3, 2020

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

fixing #7990 and #8013 by preserving variables with undefined value (note that this is not exactly how dontenv-expand works, they do replace with an empty string but since we already have a fork and has bug for undefined it can at least resolve current issue)

In rare cases to avoid conflicting part of token with env variables, it is adviced to escape like this:

TOKEN=\\$2yr\\$10\\$tN3JmuvXZKGwi0l38A.SxUVemGrFJiyLunyqkOqOTE7LHsrSwMEmEB

Some ideas for future:

  • support Token="..." syntax for .env to escape but it is being removed by dotenv (here) so not much chance unless they support it or we use a fork.
  • We could only support ${...} syntax for interpolation (suggested by @galvez) but not possible since we need a fork of dotenv and it is a breaking change
  • We could only support interpolation for runtimeConfig not dotenv which is still a breaking change

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@pi0 pi0 requested a review from a team September 3, 2020 11:31
@codecov-commenter
Copy link

Codecov Report

Merging #8013 into dev will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #8013   +/-   ##
=======================================
  Coverage   68.87%   68.87%           
=======================================
  Files          91       91           
  Lines        3849     3849           
  Branches     1043     1044    +1     
=======================================
  Hits         2651     2651           
+ Misses        972      971    -1     
- Partials      226      227    +1     
Flag Coverage Δ
#unittests 68.87% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/config/src/load.js 77.90% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 866b4dd...750361a. Read the comment docs.

@JoseJuan81
Copy link

JoseJuan81 commented Sep 8, 2020

@clarkdo @pi0 Hello, How can I use this changes in my project? I have a TOKEN in my .env and I can't use it for server http calls

This was referenced Sep 9, 2020
@pi0
Copy link
Member Author

pi0 commented Sep 10, 2020

@JoseJuan81 Please see #7990 (comment)

@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants