From dbb15289c4c34879749ab3c644df856078442ff9 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Thu, 7 May 2026 06:26:17 +0300 Subject: [PATCH] Align enum warning naming --- codex-rs/app-server/src/config_manager_service.rs | 4 ++-- .../config/src/{lenient.rs => enum_warnings.rs} | 14 +++++++------- codex-rs/config/src/lib.rs | 4 ++-- codex-rs/config/src/loader/mod.rs | 4 ++-- codex-rs/config/src/state.rs | 10 +++++----- codex-rs/core/src/config/config_loader_tests.rs | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) rename codex-rs/config/src/{lenient.rs => enum_warnings.rs} (97%) diff --git a/codex-rs/app-server/src/config_manager_service.rs b/codex-rs/app-server/src/config_manager_service.rs index 1658ddfcc3..ce02b0db6d 100644 --- a/codex-rs/app-server/src/config_manager_service.rs +++ b/codex-rs/app-server/src/config_manager_service.rs @@ -17,7 +17,7 @@ use codex_config::ConfigLayerStack; use codex_config::ConfigLayerStackOrdering; use codex_config::ConfigRequirementsToml; use codex_config::config_toml::ConfigToml; -use codex_config::enum_value_warnings; +use codex_config::invalid_enum_warnings; use codex_config::merge_toml_values; use codex_core::config::deserialize_config_toml_with_base; use codex_core::config::edit::ConfigEdit; @@ -537,7 +537,7 @@ fn toml_value_to_value(value: &TomlValue) -> anyhow::Result { } fn validate_config(value: &TomlValue) -> Result<(), toml::de::Error> { - if let Some(warning) = enum_value_warnings(value).into_iter().next() { + if let Some(warning) = invalid_enum_warnings(value).into_iter().next() { return Err(SerdeError::custom(warning)); } let _: ConfigToml = value.clone().try_into()?; diff --git a/codex-rs/config/src/lenient.rs b/codex-rs/config/src/enum_warnings.rs similarity index 97% rename from codex-rs/config/src/lenient.rs rename to codex-rs/config/src/enum_warnings.rs index 0ea481782c..9447a1338a 100644 --- a/codex-rs/config/src/lenient.rs +++ b/codex-rs/config/src/enum_warnings.rs @@ -48,13 +48,13 @@ enum CurrentNodeWarning { /// Return best-effort warnings for raw TOML values that look like invalid enums. /// -/// `DefaultOnError` is responsible for keeping config deserialization lenient. /// This pass is intentionally advisory: it walks the final merged TOML value /// against the generated config schema and reports enum-looking mismatches -/// without changing the TOML that will be deserialized. Startup loading keeps -/// these warnings non-blocking; config write paths may use the same signal to -/// reject newly provided invalid enum values. -pub fn enum_value_warnings(value: &TomlValue) -> Vec { +/// without changing the TOML that will be deserialized. Narrow typed-config +/// fallbacks keep the reported enum leaves non-blocking for startup loading; +/// config write paths may use the same signal to reject newly provided invalid +/// enum values. +pub fn invalid_enum_warnings(value: &TomlValue) -> Vec { // Startup warnings should never make config loading fail. If schema // generation or traversal panics, the typed config load still proceeds. catch_unwind(AssertUnwindSafe(|| { @@ -413,7 +413,7 @@ mod tests { fn warning_set(contents: &str) -> BTreeSet { let value = toml::from_str::(contents).expect("config should parse"); - enum_value_warnings(&value).into_iter().collect() + invalid_enum_warnings(&value).into_iter().collect() } #[test] @@ -437,7 +437,7 @@ approval_mode = "yolo" "#; let value = toml::from_str::(contents).expect("config should parse"); let original = value.clone(); - let warnings = enum_value_warnings(&value).into_iter().collect(); + let warnings = invalid_enum_warnings(&value).into_iter().collect(); let expected_warnings = BTreeSet::from([ "Ignoring invalid config value at mcp_servers.local.default_tools_approval_mode: \ \"ship-it\"" diff --git a/codex-rs/config/src/lib.rs b/codex-rs/config/src/lib.rs index 6c405b1f2f..9e5355c09c 100644 --- a/codex-rs/config/src/lib.rs +++ b/codex-rs/config/src/lib.rs @@ -3,11 +3,11 @@ mod config_requirements; pub mod config_toml; mod constraint; mod diagnostics; +mod enum_warnings; mod fingerprint; mod hook_config; mod host_name; mod key_aliases; -mod lenient; pub mod loader; mod marketplace_edit; mod mcp_edit; @@ -72,6 +72,7 @@ pub use diagnostics::first_layer_config_error_from_entries; pub use diagnostics::format_config_error; pub use diagnostics::format_config_error_with_source; pub use diagnostics::io_error_from_config_error; +pub use enum_warnings::invalid_enum_warnings; pub use fingerprint::version_for_toml; pub use hook_config::HookEventsToml; pub use hook_config::HookHandlerConfig; @@ -81,7 +82,6 @@ pub use hook_config::HooksToml; pub use hook_config::ManagedHooksRequirementsToml; pub use hook_config::MatcherGroup; pub use host_name::host_name; -pub use lenient::enum_value_warnings; pub use marketplace_edit::MarketplaceConfigUpdate; pub use marketplace_edit::RemoveMarketplaceConfigOutcome; pub use marketplace_edit::record_user_marketplace; diff --git a/codex-rs/config/src/loader/mod.rs b/codex-rs/config/src/loader/mod.rs index 00b9f9ae94..029aec5781 100644 --- a/codex-rs/config/src/loader/mod.rs +++ b/codex-rs/config/src/loader/mod.rs @@ -894,7 +894,7 @@ pub fn resolve_relative_paths_in_config_toml( /// Ensure that every field in `original` is present in the returned /// `toml::Value`, copying only the absolute path strings produced by the typed -/// round-trip. Other leaves stay raw so lenient enum defaults do not overwrite +/// round-trip. Other leaves stay raw so enum fallback defaults do not overwrite /// the value that should produce a startup warning. fn copy_shape_from_original(original: &TomlValue, resolved: &TomlValue) -> TomlValue { match (original, resolved) { @@ -919,7 +919,7 @@ fn copy_shape_from_original(original: &TomlValue, resolved: &TomlValue) -> TomlV } (TomlValue::String(original), TomlValue::String(resolved)) => { // Relative path normalization turns a string into a different - // absolute path string. Lenient enum defaults can also change a + // absolute path string. Enum fallback defaults can also change a // string, but those default strings are not absolute paths and must // not replace the user's raw value before warning collection. if original != resolved && Path::new(resolved).is_absolute() { diff --git a/codex-rs/config/src/state.rs b/codex-rs/config/src/state.rs index f8561956a7..374e0e8ae4 100644 --- a/codex-rs/config/src/state.rs +++ b/codex-rs/config/src/state.rs @@ -1,10 +1,10 @@ use crate::config_requirements::ConfigRequirements; use crate::config_requirements::ConfigRequirementsToml; +use super::enum_warnings::invalid_enum_warnings; use super::fingerprint::record_origins; use super::fingerprint::version_for_toml; use super::key_aliases::normalized_with_key_aliases; -use super::lenient::enum_value_warnings; use super::merge::merge_toml_values; use crate::config_toml::ConfigToml; use codex_app_server_protocol::ConfigLayer; @@ -320,14 +320,14 @@ impl ConfigLayerStack { /// Deserializes the merged config-layer view and returns any soft warnings. /// - /// Invalid enum-valued settings are handled by `DefaultOnError` during - /// deserialization. Warnings are collected from the final raw TOML view so - /// warning discovery remains advisory and cannot change config semantics. + /// Invalid enum-valued settings are reported from the final raw TOML view. + /// Narrow typed-config fallbacks keep those warnings advisory without + /// changing unrelated config semantics. pub fn deserialize_effective_config_with_warnings( &self, ) -> Result<(TomlValue, ConfigToml, Vec), toml::de::Error> { let merged = self.effective_config(); - let warnings = enum_value_warnings(&merged); + let warnings = invalid_enum_warnings(&merged); let typed = merged.clone().try_into::()?; Ok((merged, typed, warnings)) } diff --git a/codex-rs/core/src/config/config_loader_tests.rs b/codex-rs/core/src/config/config_loader_tests.rs index c0d56e2bb6..d3f2ba309a 100644 --- a/codex-rs/core/src/config/config_loader_tests.rs +++ b/codex-rs/core/src/config/config_loader_tests.rs @@ -150,7 +150,7 @@ context_size = "galactic" .await?; // The warning pass reads the final TOML value without mutating it, while - // DefaultOnError lets unrelated valid settings still deserialize. + // field-level fallbacks let unrelated valid settings still deserialize. let (effective_config, _config_toml, enum_warnings) = layers.deserialize_effective_config_with_warnings()?; let expected_config = toml::from_str::(