rust-cli / rust-cli/config-rs

Integer values are limited by 2^63-1 (9223372036854775807).

Open
#332 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.2k
Forks
265
Avg merge
2h 42m
Merged PRs (30d)
4

Description

Greetings!

Is there is a bug what integers are limited by 2^63-1?

use config::{Config, Environment, File, FileFormat};

fn main() {
    // Ok
    println!(
        "number: `{}`.",
        read_conf().get::<u64>("data.number").unwrap()
    );

    // Ok
    std::env::set_var("PREFIX_data.number", (1u64 << 63 - 1).to_string());
    println!(
        "number: `{}`.",
        read_conf().get::<u64>("data.number").unwrap()
    );

    // Error
    std::env::set_var("PREFIX_data.number", (1u64 << 63).to_string());
    println!(
        "number: `{}`.",
        read_conf().get::<u64>("data.number").unwrap_err()
    );
}

#[inline]
fn read_conf() -> Config {
    Config::builder()
        .add_source(File::from_str("[data]\nnumber = 1024", FileFormat::Toml))
        .add_source(Environment::with_prefix("PREFIX"))
        .build()
        .unwrap()
}

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 Config builder and Environment source shown in the reproduction, then trace how the environment value is parsed and converted by get::. Check existing tests for environment sources or integer deserialization. Done means the reproduced u64 boundary case behaves correctly and regression coverage records the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.