rust-cli / rust-cli/config-rs

Incorrectly deserializes upper case unquoted `INF` string value from a YAML file

Open
#568 0 comments 0 reactions 0 assignees View on GitHub

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 INF value is deserialized to a String as "INF"
  • The test passes

Actual results

  • The INF value is deserialized to a String as "inf"
  • The test fails

Notes

  • The problem is that INF is deserialized to some internal representation as a float +Inf value before it is deserialized to a String.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.