From 567476d7dfff5a3723f51320f53ae6021d51d638 Mon Sep 17 00:00:00 2001 From: Eeshu-Yadav Date: Tue, 21 Oct 2025 22:11:58 +0530 Subject: [PATCH] Fix unsupported_field! macro to properly handle recursive cases - Fixed macro to return Result::<(), GenericError>::Ok(()) correctly - Recursive case now properly propagates return value - Changed behavior from hard error to graceful warning - Unsupported fields like alt_stat_name are now ignored with warnings This resolves issue #41 where alt_stat_name caused config parsing to fail. The macro now logs a warning and continues parsing instead of crashing. Signed-off-by: Eeshu-Yadav --- orion-configuration/src/config/common.rs | 36 +++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/orion-configuration/src/config/common.rs b/orion-configuration/src/config/common.rs index df273cf3..b2627104 100644 --- a/orion-configuration/src/config/common.rs +++ b/orion-configuration/src/config/common.rs @@ -341,26 +341,28 @@ pub(crate) mod envoy_conversions { // it would be nice to allow for x = "y" syntax to overwrite the field name, since some fields are // named differently in the code vs config file and having the code-local name might confuse an end-user macro_rules! unsupported_field { - ($field:ident) => { + ($field:ident) => {{ if $field.is_used() { - #[allow(dropping_copy_types, clippy::drop_non_drop)] - drop($field); - Err(GenericError::UnsupportedField(stringify!($field))) - } else { - #[allow(dropping_copy_types, clippy::drop_non_drop)] - drop($field); - Ok(()) + tracing::warn!( + "unsupported field '{}' used in configuration. This field will be ignored.", + stringify!($field) + ); } - }; - ($field:ident, $($tail:ident),+) => { - if $field.is_used() { - #[allow(dropping_copy_types, clippy::drop_non_drop)] - drop($field); - Err(GenericError::UnsupportedField(stringify!($field))) - } else { - unsupported_field! ($($tail),+) + #[allow(dropping_copy_types, clippy::drop_non_drop)] + drop($field); + Result::<(), GenericError>::Ok(()) + }}; + ($field:ident, $($tail:ident),+) => {{ + if $field.is_used() { + tracing::warn!( + "unsupported field '{}' used in configuration. This field will be ignored.", + stringify!($field) + ); } - }; + #[allow(dropping_copy_types, clippy::drop_non_drop)] + drop($field); + unsupported_field!($($tail),+) + }}; } pub(crate) use unsupported_field;