-
Notifications
You must be signed in to change notification settings - Fork 204
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
Non-deterministic results for overlapping overrides #442
Comments
I agree that this can be an issue. From what I see the solution for this would be to use an BTreeMap or something similar in the implementation, right? |
Yes, although for compatibility you may want to keep the trait as is, and sort afterwards. Alternatively a breaking api change to BTreeMap would mean that the implementations need to handle determinism (ex. by sorting env vars for env var source). |
So Could you maybe provide a PR with a (failing, of course) testcase for above example? I think we can then go from there... changing the impl from HashMap to BTreeMap should be a rather trivial patch I think... |
Testing something non-deterministic sounds like a recipe for a flaky test, maybe unnecessary in this case. If the patch is straightforward I think it makes sense to go straight to that. |
Source::collect returns a config::Map which is a HashMap. HashMap traversals are unordered, so the processing order of a Source is non-deterministic.
This can be an issue if multiple values in the Source affect the same data:
This can result in deserializing 1..3 or 1..5 randomly.
The text was updated successfully, but these errors were encountered: