-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Duplicate keys in *.app env entry causes -config option to be ignored #5877
Comments
Admittedly, having duplicate keys in |
So what happens is this: > Keys = application_controller:merge_app_env([{key1,app1},{key1,app2}],[{key1,config1}]).
[{key1,config1},{key1,app2}].
> [ets:insert(ac_tab, Tuple) || Tuple <- Keys].
[ok, ok]. That is, the config value gets merged into the first key and then the first key gets overwritten by the second key when the environment is inserted in the application_controller table. This is obviously a bug, but I'm unsure what to do about it. Either reject any .app file with duplicate keys defined, or normalize the .app env values before merging with the sys.config value. |
Reject, I would say. The 11:09 $ erl -config dups.config
{"could not start kernel pid",application_controller,"invalid config data: application: kdb; duplicate parameter: key1"}
could not start kernel pid (application_controller) (invalid config data: application: kdb; duplicate parameter: key1)
Crash dump is being written to: erl_crash.dump...done |
Although rejecting might have some backwards compatibility issues which hits existing applications. |
I did not realize that -config already rejected duplicate keys. Seems reasonable that .app files should follow the same logic. |
A potential fix is available in #5878. I'm not sure if I want to make this part of Erlang/OTP 25, or leave it for 26. It has just missed the window for the last rc and we don't like to add additional potentially breaking changes after the final rc. |
I'm fine with leaving it for OTP 26. |
Describe the bug
If an OTP application has duplicate keys in the
env
sections of it's*.app
file, any file specified using the-config
option toerl
is ignored, and instead value of the last duplicate key is used.To Reproduce
rebar3 new testapp
*.app.src
:sys.config
file with an override:erl
and print the app env:key1
is the duplicate value intestapp.app.src
, not the override in thesys.config
file.testapp.app.src
:Then the override takes precedence as expected:
Expected behavior
According to the docs:
So, I would expect the value
key1
to always be10_this_value_comes_from_sysconfig
, overriding any value intestapp.app.src
.Affected versions
I've been able to reproduce this in OTP-22.3.4.20, OTP-23.3.4.2, OTP-24.1.3, OTP-24.2.1, OTP-25.0-rc1
The text was updated successfully, but these errors were encountered: