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

EnvFile fails to parse well-formed yaml files #213

Open
cmmoran opened this issue Mar 6, 2023 · 0 comments · May be fixed by #211
Open

EnvFile fails to parse well-formed yaml files #213

cmmoran opened this issue Mar 6, 2023 · 0 comments · May be fixed by #211

Comments

@cmmoran
Copy link

cmmoran commented Mar 6, 2023

The yaml spec supports strings with or without single or double quotes. The following are considered identical:

Sample String
"Sample String"
'Sample String'

EnvFile can read yaml files as environment definitions. When EnvFile does so, it assumes all values for keys will be string. This may not necessarily be the case. For example, a trivial application may have a config file:

foo: bar
bar: 42

EnvFile will be unable to parse this yaml because bar will resolve as an integer and a resulting ClassCastException will be thrown.

Note: This exception is insidious because if the IDE was attempting to execute a Run Configuration when this exception occurred, the associated Toolbar button in the JetBrains IDE will be greyed out until the IDE is restarted

The trivial application developer(s) could be required to specify a separate config file just for EnvFile to be able to parse:

foo: bar
bar: "42"

This yaml would be properly read by EnvFile and provide the foo and bar environment variables at runtime.

This feels like a less-optimal solution. It requires maintaining two nearly identical configuration files when one can (and arguably should) be sufficient. It seems reasonable that EnvFile properly read a yaml file and attempt a gentle coercion (if possible) by simply attempting String.valueOf on the parsed yaml values. This will yield the expected Map<String,String> for EnvFile to use.

@cmmoran cmmoran linked a pull request Mar 6, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant