-
Notifications
You must be signed in to change notification settings - Fork 18
Fix unsupported_field! macro to properly handle recursive cases #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix unsupported_field! macro to properly handle recursive cases #121
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary of ChangesHello @Eeshu-Yadav, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness of configuration parsing by modifying the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the unsupported_field! macro to handle unsupported configuration fields gracefully by logging warnings instead of causing parsing failures.
Key Changes:
- Changed macro behavior from returning errors to logging warnings and continuing execution
- Fixed the recursive case to properly propagate the return value from nested macro invocations
- Ensured both branches consistently return
Result::<(), GenericError>::Ok(())
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| #[allow(dropping_copy_types, clippy::drop_non_drop)] | ||
| drop($field); |
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The drop($field) call in the else branch is redundant. Since the field is not used (as verified by the is_used() check), dropping it here serves no purpose and can be removed for clarity.
| drop($field); | ||
| } | ||
| }; | ||
| unsupported_field!($($tail),+) |
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recursive call to unsupported_field! is missing a return statement or value propagation. The result of this recursive call should be returned, otherwise the recursion will expand but its result will be discarded. Consider wrapping this in a return or ensuring the value is properly used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request modifies the unsupported_field! macro in orion-configuration/src/config/common.rs to handle recursive cases properly and change the behavior from a hard error to a graceful warning. The macro now logs a warning and continues parsing instead of crashing when encountering unsupported fields. The changes ensure that the macro returns Result::<(), GenericError>::Ok(()) correctly and propagates the return value in recursive cases. I have identified a potential issue with the macro's recursive call and provided a suggestion to ensure the intended behavior.
| drop($field); | ||
| } | ||
| }; | ||
| unsupported_field!($($tail),+) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recursive call unsupported_field!($($tail),+) might not return the Result as intended because the outer block will always return Ok(()). Consider returning the result of the recursive call to propagate any potential errors.
I'm not sure if this is the intended behavior, but it's something to consider.
| unsupported_field!($($tail),+) | |
| unsupported_field!($($tail),+)? |
- 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 kmesh-net#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]>
739e3a3 to
567476d
Compare
|
@dawid-nowak this one also |
|
@hzxuzhonghu this one |
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.