Skip to content

Commit 567476d

Browse files
committed
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 <[email protected]>
1 parent 1399147 commit 567476d

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

orion-configuration/src/config/common.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -341,26 +341,28 @@ pub(crate) mod envoy_conversions {
341341
// it would be nice to allow for x = "y" syntax to overwrite the field name, since some fields are
342342
// named differently in the code vs config file and having the code-local name might confuse an end-user
343343
macro_rules! unsupported_field {
344-
($field:ident) => {
344+
($field:ident) => {{
345345
if $field.is_used() {
346-
#[allow(dropping_copy_types, clippy::drop_non_drop)]
347-
drop($field);
348-
Err(GenericError::UnsupportedField(stringify!($field)))
349-
} else {
350-
#[allow(dropping_copy_types, clippy::drop_non_drop)]
351-
drop($field);
352-
Ok(())
346+
tracing::warn!(
347+
"unsupported field '{}' used in configuration. This field will be ignored.",
348+
stringify!($field)
349+
);
353350
}
354-
};
355-
($field:ident, $($tail:ident),+) => {
356-
if $field.is_used() {
357-
#[allow(dropping_copy_types, clippy::drop_non_drop)]
358-
drop($field);
359-
Err(GenericError::UnsupportedField(stringify!($field)))
360-
} else {
361-
unsupported_field! ($($tail),+)
351+
#[allow(dropping_copy_types, clippy::drop_non_drop)]
352+
drop($field);
353+
Result::<(), GenericError>::Ok(())
354+
}};
355+
($field:ident, $($tail:ident),+) => {{
356+
if $field.is_used() {
357+
tracing::warn!(
358+
"unsupported field '{}' used in configuration. This field will be ignored.",
359+
stringify!($field)
360+
);
362361
}
363-
};
362+
#[allow(dropping_copy_types, clippy::drop_non_drop)]
363+
drop($field);
364+
unsupported_field!($($tail),+)
365+
}};
364366

365367
}
366368
pub(crate) use unsupported_field;

0 commit comments

Comments
 (0)