-
Notifications
You must be signed in to change notification settings - Fork 55
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
Issue: Danger handling of environment variables [with missing values] #118
Comments
Hmm that's definitely a fun bug. I think the right approach would be to allow escaping the expansion (like |
Escaping the $ with |
@sethvargo please review. Can be done this way
|
Hi @rodkevich - this isn't a use case I'd like to support. I've intentionally kept the API as succinct as possible. I think the best path forward is to add something a new option like "noexpand" that disables |
This is not just an issue with os.Expand, but also with other features specific to [default] behavior. The main concern is how to disable these automatic transformations and use the environment variable’s literal value as-is, without any further processing The issue is that the person writing the code and the one setting the environment variables are not always the same. They might not even realize what’s happening — everything seems correct in the manifests, and the app worked in one environment, but in another, it doesn’t work. =) From my perspective, the simplest solution would be to introduce an option that completely disables all modifications — something like raw=, literal=, or strict=, depending on preference. This would allow developers to explicitly opt out of processing, while keeping the default behavior for cases where they are 100% confident no issues will arise. It would be helpful if you could provide an example of how you envision this working with JSON tags |
Description:
When processing environment variables using os.Expand (specifically when expanding defaultValue), if the environment variable is not found, the current implementation replaces the placeholder with an empty string (""). As a result, the $ symbol and the variable name are removed from the string, leading to unexpected behavior.
Potential Risk:
This issue can cause subtle bugs where a missing environment variable results in the loss of 2 chars.
The team may end up searching for the root cause for hours =)
Modified test from examples
:A possible fix would be to return the extracted part with the dollar sign $ included, like this:
However, this approach would alter the original author's assumption that missing environment variables should return an empty string.
The text was updated successfully, but these errors were encountered: