mehcode / config-rs

⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Apache License 2.0
2.43k stars 206 forks source link

Non-deterministic selection of deserializer #501

Open vigoo opened 7 months ago

vigoo commented 7 months ago

I ran into an issue where something seems to randomly choose from representing an integer field to be deserialized as either config's Value, or serde's Content. When it is the the first, the into_uint logic in Value correctly parses the string configuration (coming from an Environment source) but when it is running into deserializing Content::String then it fails with

Failed to parse config: invalid type: string "1234", expected u16

I could not figure out where the non-determinism is coming from.

The following repository reproduces the problem: https://github.com/vigoo/rust-config-bug

just running cargo run multiple times, sometimes it works, sometimes fails with the above error.