Skip to content

Commit 5fd2496

Browse files
committed
fix: use ClapSerde::Opt for config deserialization to respect defaults
When deserializing the TOML config file directly into AppConfig, serde's #[serde(default)] attribute was using Rust's Default trait for bool (false) instead of the #[default(true)] attribute which only applies to the Default trait implementation generated by ClapSerde. Fix by deserializing into <AppConfig as ClapSerde>::Opt first, then converting via AppConfig::from() which properly applies the defaults. Also add default_value to always-uv CLI argument for consistency. Update soft-fido2 to 0.12.2 which includes the duplicate notification fix.
1 parent 595f781 commit 5fd2496

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ repository = "https://github.com/pando85/passless"
1414
passless-core = { path = "./passless-core", version = "0.9.2" }
1515
passless-config-doc = { path = "./passless-config-doc", version = "0.9.2" }
1616

17-
soft-fido2 = "0.12.1"
18-
soft-fido2-ctap = "0.12.1"
19-
soft-fido2-transport = "0.12.1"
17+
soft-fido2 = "0.12.2"
18+
soft-fido2-ctap = "0.12.2"
19+
soft-fido2-transport = "0.12.2"
2020

2121
thiserror = "2.0"
2222
clap = { version = "4.5", features = ["std", "color", "derive", "cargo", "env"] }

passless-core/src/config.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ pub struct SecurityConfig {
159159
action = ArgAction::Set,
160160
require_equals = true,
161161
num_args = 0..=1,
162+
default_value = "true",
162163
default_missing_value = "true"
163164
)]
164165
#[serde(default)]
@@ -420,10 +421,10 @@ impl AppConfig {
420421
{
421422
log::info!("Loading configuration from: {}", path.display());
422423
let content = std::io::read_to_string(BufReader::new(f)).unwrap_or_default();
423-
match toml::from_str::<AppConfig>(&content) {
424+
match toml::from_str::<<AppConfig as ClapSerde>::Opt>(&content) {
424425
Ok(file_config) => {
425-
// Merge: file config + CLI args (CLI takes precedence)
426-
return file_config.merge(&mut args.config);
426+
// Deserialize into Opt, then convert with defaults and merge CLI args
427+
return AppConfig::from(file_config).merge(&mut args.config);
427428
}
428429
Err(e) => log::warn!("Failed to parse config file {}: {}", path.display(), e),
429430
}

0 commit comments

Comments
 (0)