fix: Fix special char handling in pre-define env #11799
Merged
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.
When starting the fat container with
APPSMITH_MONGODB_URI
variable set to a value that has query params, likemongodb+srv://user:pass@appsmith.abcde.mongodb.net/testdb?retryWrites=true&w=majority
, then the fat container ignores it and goes ahead with using a local MongoDB server.The problem is that we generated a
pre-define.env
file, that gets the following line (among many others like it):This file is then sourced with
. pre-define.env
. When this runs, this file is evaluated like a shell script, and the shell's glob based file-name expansions take affect.So for this line, the shell looks for a file that looks like
mongodb+srv://user:pass@appsmith.abcde.mongodb.net/testdb?retryWrites=true&w=majority
, where there's any letter in place of the?
, which is the glob definition of?
character. Since it doesn't find any such files, it will turn this line into justAPPSMITH_MONGODB_URI=
, indicating that there's no files to expand the glob pattern into.Now since the
APPSMITH_MONGODB_URI
is set to empty value, the fat container will proceed to use it's local MongoDB just fine.This can be avoided by wrapping the value in quotes. Like
APPSMITH_MONGODB_URI='mongodb+srv://user:pass@appsmith.abcde.mongodb.net/testdb?retryWrites=true&w=majority'
In this case, the shell will take the value verbatim and won't attempt to do glob expansion (or any potential variable expansion, if the value has any
$
characters in it).This PR adds a
sed
transformation to the generation ofpre-define.env
that:'
in each line with'"'"'
, which is kind of an escaped single-quote, in a single-quoted string.'
just after the=
sign on each line.'
at the end of each line.Type of change
How Has This Been Tested?