Non-deterministic results for overlapping overrides
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 265
- Avg merge
- 2h 42m
- Merged PRs (30d)
- 4
Description
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:
#[derive(Debug, Serialize, Deserialize)]
struct TestConfig {
nested: std::ops::Range<i32>,
}
impl Source for ExampleSource {
fn collect(&self) -> Result<config::Map<String, config::Value>, config::ConfigError> {
Ok([
("nested".to_string(), config::Value::new(None, config::ValueKind::String("{\"start\": 1, \"end\": 3}".to_string())),
("nested.end".to_string(), config::Value::new(None, config::ValueKind::String("5".to_string()))),
].into_iter().collect())
}
}
This can result in deserializing 1..3 or 1..5 randomly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting Source::collect and the config::Map type, then run the provided ExampleSource reproducer repeatedly to observe the overlapping overrides. Trace how collected values are processed and determine where ordering is lost. Done means overlapping values produce the same deserialized result consistently, with coverage for the 1..3 versus 1..5 case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100