rust-cli / rust-cli/config-rs

Can't parse an empty array with the env parser

Open
#443 0 comments 6 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 am trying to parse a vec key with Env (with env TEST_KEY__LIST = "") source like

Environment::with_prefix("TEST")
        .try_parsing(true)
        .prefix_separator("_")
        .separator("__")
        .list_separator(",")
        .with_list_parse_key("test_key.enable")
struct Config {
  test_key: TestKey
}

enum Test {
  One,
  Two
}

struct TestKey {
  enable: Vec<Test>
}

and I see

invalid type: string "", expected a sequence

I assume that the empty string should be parsed as an empty array

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

Use the Environment::with_prefix("TEST") configuration and the empty TEST_KEY__LIST value as the reproduction entry point. Trace the environment list parsing path and add or update a regression test for an empty list. Done means the empty string is accepted as an empty Vec while non-empty values retain their current parsing behavior.

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.