rust-cli / rust-cli/config-rs

Non-deterministic selection of deserializer

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

Nobody has claimed this yet.

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

Description

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.

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 linked reproducer and run cargo run repeatedly to confirm the intermittent failure. Trace how integer fields are deserialized when the source is an environment value, particularly the paths involving config's Value and serde's Content. Done means the reproducer no longer changes behavior between runs and the failure is covered by a regression test.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.