If I add multiple sources, but one of them fails. Does the whole parse fail?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 265
- Avg merge
- 2h 42m
- Merged PRs (30d)
- 4
Description
If I add 2-3 sources like code.
let config = Config::builder()
.add_source(File::from_str(CONFIG_DATA, config::FileFormat::Toml))//source1
.add_source( //source2
config::Environment::with_prefix(APP_NAME.to_uppercase().as_str())
.try_parsing(true)
.separator("_")
.list_separator(","),
);
let res = config.add_source(File::with_name(config_path.to_str().expect("Failed to convert path to string")))source3
.build()
.map_err(|e| {
error!("Failed to load config: {:?}", e);
e
});
This code, which returns ConfigError。so,I can't try_deserialize
My expectation is that because add_source is added sequentially, the parsing before a layer fails will still work. This way it won't be possible for one misconfiguration to cause the whole application to fall back to the default configuration on startup, which can cause huge failures. Still, config-rs does not deal with this problem, and it is up to the user to fall back on the importance if necessary.
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 by tracing Config::builder(), add_source, and build() to see how source errors are collected and exposed through ConfigError. Review existing tests for layered sources and failures, then determine what behavior and API would be needed for earlier sources to remain usable when a later source fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100