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

Dotenv parsing errors should show filename #12614

Open
hanikesn opened this issue Mar 7, 2025 · 1 comment
Open

Dotenv parsing errors should show filename #12614

hanikesn opened this issue Mar 7, 2025 · 1 comment

Comments

@hanikesn
Copy link

hanikesn commented Mar 7, 2025

Description

Recently we had to debug the following error in a moderately complex compose setup:

line xx: unexpected character "{" in variable name "{"

It later turned out to be a syntax error in one of the .env files included. It would have been very helpful if the error would also shown the affected file. The error originates here:

https://github.com/compose-spec/compose-go/blob/d2fae8edbd9fa258520dc2aa85399bb74819bc52/dotenv/parser.go#L130

And this seems to be the call site:

envFromFile, err := dotenv.GetEnvFromFile(composegoutils.GetAsEqualsMap(os.Environ()), options.EnvFiles)
if err != nil {
return nil
}

@ndeloof
Copy link
Contributor

ndeloof commented Mar 10, 2025

Indeed, would you like to contribute and propose a Pull Request on https://github.com/compose-spec/compose-go to improve this ?

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

No branches or pull requests

2 participants