Incorrectly deserializes upper case unquoted `INF` string value from a YAML file
Open
Nobody has claimed this yet.
A-format
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 265
- Avg merge
- 2h 42m
- Merged PRs (30d)
- 4
Description
Description
Here is the minimal test set to reproduce the issue
Source Files
assets/config.yaml
val: INF
src/lib.rs
#[cfg(test)]
mod tests {
use config::Config;
use serde::Deserialize;
#[test]
fn test_yaml_inf() {
#[derive(Deserialize)]
struct Settings {
pub val: String,
}
let cfg = Config::builder()
.add_source(config::File::with_name("assets/config.yaml"))
.build()
.unwrap();
let settings = cfg.try_deserialize::<Settings>().unwrap();
assert_eq!(settings.val, "INF");
}
}
Cargo.toml
[package]
name = "hl-issue-288"
version = "0.1.0"
edition = "2021"
[dependencies]
config = { version = "0", features = ["yaml"] }
serde = { version = "1", features = ["derive"] }
Expected results
- The
INFvalue is deserialized to aStringas"INF" - The test passes
Actual results
- The
INFvalue is deserialized to aStringas"inf" - The test fails
Notes
- The problem is that
INFis deserialized to some internal representation as a float+Infvalue before it is deserialized to aString.
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 with the minimal reproducer in src/lib.rs and assets/config.yaml, using the Cargo.toml dependencies shown in the issue. Run the test to confirm that unquoted INF becomes "inf" instead of "INF", then trace the YAML source through deserialization. Done means the test passes while preserving the exact uppercase string.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, yaml
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100