Align enum warning naming

This commit is contained in:
Ahmed Ibrahim
2026-05-07 06:26:17 +03:00
parent a21345c5f9
commit dbb15289c4
6 changed files with 19 additions and 19 deletions
@@ -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<toml_edit::Value> {
}
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()?;
@@ -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<String> {
/// 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<String> {
// 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<String> {
let value = toml::from_str::<TomlValue>(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::<TomlValue>(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\""
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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() {
+5 -5
View File
@@ -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<String>), 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::<ConfigToml>()?;
Ok((merged, typed, warnings))
}
@@ -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::<TomlValue>(