Skip to content

Commit 739e3a3

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 739e3a3

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

orion-configuration/src/config/common.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -341,26 +341,34 @@ 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+
tracing::warn!(
347+
"unsupported field '{}' used in configuration. This field will be ignored.",
348+
stringify!($field)
349+
);
346350
#[allow(dropping_copy_types, clippy::drop_non_drop)]
347351
drop($field);
348-
Err(GenericError::UnsupportedField(stringify!($field)))
349352
} else {
350353
#[allow(dropping_copy_types, clippy::drop_non_drop)]
351354
drop($field);
352-
Ok(())
353355
}
354-
};
355-
($field:ident, $($tail:ident),+) => {
356-
if $field.is_used() {
356+
Result::<(), GenericError>::Ok(())
357+
}};
358+
($field:ident, $($tail:ident),+) => {{
359+
if $field.is_used() {
360+
tracing::warn!(
361+
"unsupported field '{}' used in configuration. This field will be ignored.",
362+
stringify!($field)
363+
);
357364
#[allow(dropping_copy_types, clippy::drop_non_drop)]
358365
drop($field);
359-
Err(GenericError::UnsupportedField(stringify!($field)))
360366
} else {
361-
unsupported_field! ($($tail),+)
367+
#[allow(dropping_copy_types, clippy::drop_non_drop)]
368+
drop($field);
362369
}
363-
};
370+
unsupported_field!($($tail),+)
371+
}};
364372

365373
}
366374
pub(crate) use unsupported_field;

0 commit comments

Comments
 (0)