-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
.get defaultValue is bypassed when env was set to undefined #42
Comments
Can you please create failing test for this? Because as per this logic https://github.com/adonisjs/env/blob/6.x/src/env.ts#L121-L124 the default value should be returned. |
please refer to the testcase added here |
resolves adonisjs#42: When an env value was undefined and set to a value, then manually set to undefined again, env.get('VAR', 'DEFAULT') would not return the correct default value.
spotted a potential fix. created a PR |
This issue has been marked as stale because it has been inactive for more than 21 days. Please reopen if you still need help on this issue |
This issue has been automatically closed because it has been inactive for more than 4 weeks. Please reopen if you still need help on this issue |
Edited/20250129
Package version
6.1.1
Describe the bug
When an env variable is cleared by executing
env.set("MY_VAR", undefined)
orprocess.env.MY_VAR = undefined
,env.get("MY_VAR", "DEFAULT")
will returnundefined
.This is kind of a rare usage but it is very useful for testing how adonis configuration react to env var changes.
Reproducing steps
process.env.MY_VAR
is undefinedenv.set('MY_VAR', 'new value')
env.set('MY_VAR', undefined)
assert(env.get('MY_VAR', "DEFAULT"))
Expected behavior
env.get("MY_VAR", "DEFAULT")
should still return"DEFAULT"
Actual behavior
env.get("MY_VAR", "DEFAULT")
returnsundefined
Reproduction repo
https://github.com/jcppman/adonis-env/tree/reprod-env-default
The text was updated successfully, but these errors were encountered: