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

Possible double-recursive expansion regression #120

Closed
mschoeffmann opened this issue Feb 17, 2024 · 5 comments
Closed

Possible double-recursive expansion regression #120

mschoeffmann opened this issue Feb 17, 2024 · 5 comments

Comments

@mschoeffmann
Copy link

mschoeffmann commented Feb 17, 2024

In addition to #117, there is also a breaking change when referencing a "real" env variable from a .env file.

For example:

Variable (set in docker environment):
APP_DOMAIN=example.com

Variable (set in .env):
BASE_URL=https://${APP_DOMAIN}/api/

Results in https://${APP_DOMAIN}/api/.
In v10 it was correct: https://example.com/api/

@motdotla
Copy link
Owner

this appears to be working correctly @mschoeffmann. here's a test demonstrating it. https://github.com/motdotla/dotenv-expand/pull/121/files

what does your dotenv.config and dotenvExpand code look like? keep in mind we removed ignoreProcessEnv and replaced it with processEnv (https://github.com/motdotla/dotenv-expand/blob/master/CHANGELOG.md#removed). possibly are you using the processEnv argument to dotenv.config ?

@mschoeffmann
Copy link
Author

mschoeffmann commented Feb 17, 2024

The variable DEVCONTAINER_CADDY_PUBLIC_DOMAIN is set to mydom.test in a Devcontariner's docker-compose file and is available.

My corresponding part of my app's config is:

console.log('BEFORE >>>'); // for demo
Object.entries(process.env).map((x) => x[0].indexOf('PUBLIC_') >= 0 && console.log(x)); // for demo
const devEnv = dotenv.config({ path: path.resolve(require.main.path, '../../.env') });
dotenvExpand.expand(devEnv);
console.log('AFTER >>>'); // for demo
Object.entries(process.env).map((x) => x[0].indexOf('PUBLIC_') >= 0 && console.log(x)); // for demo

The corrsponding .env entries:

PUBLIC_DOMAIN="${DEVCONTAINER_CADDY_PUBLIC_DOMAIN}"
PUBLIC_BASE_URL="https://${PUBLIC_DOMAIN}"
PUBLIC_API_BASE_URL="/api/v1"

Outputs:

BEFORE >>>
[ 'DEVCONTAINER_CADDY_PUBLIC_DOMAIN', 'mydom.test' ]
AFTER >>>
[ 'DEVCONTAINER_CADDY_PUBLIC_DOMAIN', 'mydom.test' ]
[ 'PUBLIC_DOMAIN', 'mydom.test' ]
[ 'PUBLIC_BASE_URL', 'https://${DEVCONTAINER_CADDY_PUBLIC_DOMAIN}' ]
[ 'PUBLIC_API_BASE_URL', '/api/v1' ]

So, sorry, it's not about the variable itself, it's about the double recursion: PUBLIC_BASE_URL < PUBLIC_DOMAIN < DEVCONTAINER_CADDY_PUBLIC_DOMAIN

@mschoeffmann mschoeffmann changed the title Possible recursive expansion regression - The 2nd Possible double-recursive expansion regression Feb 17, 2024
@motdotla
Copy link
Owner

confirmed issue here: #121

sorry about this. working on patch.

@motdotla
Copy link
Owner

that one was tricky to track down but is done now. https://github.com/motdotla/dotenv-expand/pull/121/files

install 11.0.5 and you should be all set

@mschoeffmann
Copy link
Author

I can confirm: 11.0.5 is working.
Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants