refactor(staking-cli): move skip-metadata-validation to command args#3937
refactor(staking-cli): move skip-metadata-validation to command args#3937
Conversation
Move --skip-metadata-validation from global flag to MetadataUriArgs, making it a command-specific flag that appears after the subcommand. Changes: - Move skip_metadata_validation field to MetadataUriArgs - Refactor metadata_uri to Option<Url> with custom value parser - Add Clap constraints: requires, conflicts_with, required_unless_present - Move MetadataUriArgs to metadata.rs for better organization - Add tests for expected error messaged. Breaking change: --skip-metadata-validation must now appear after the subcommand instead of before it. Before: staking-cli --skip-metadata-validation register-validator ... After: staking-cli register-validator ... --skip-metadata-validation
|
/gemini review |
Summary of ChangesHello @sveitser, 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 refactors the staking-cli to improve the handling of metadata URI validation. It moves the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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.
Code Review
This pull request is a great refactoring that moves the --skip-metadata-validation flag from a global option to a command-specific argument within MetadataUriArgs. This change significantly improves the CLI's usability and structure by making argument relationships more explicit and less error-prone, enforced by clap constraints. The code is well-organized, with logic moved to the appropriate modules, and the changes are thoroughly tested, including new tests for the CLI argument constraints. The breaking change is well-documented and justified. My feedback includes a couple of minor suggestions to enhance code robustness and test maintainability.
There was a problem hiding this comment.
Code Review
The pull request successfully refactors the --skip-metadata-validation flag, moving it from a global option to a command-specific argument within MetadataUriArgs. This change significantly improves the CLI's argument parsing logic by making the flag's applicability more explicit and enforcing logical constraints. The README.md documentation has been updated to reflect this breaking change, providing clear examples of the new usage. The core logic for handling metadata arguments, including a custom URL parser with a byte limit, has been cleanly moved to metadata.rs. The implementation of clap attributes such as required_unless_present, conflicts_with, and requires for the new argument structure is well-done, ensuring robust and intuitive CLI behavior. Furthermore, the extensive updates and additions to the test suite thoroughly validate these new argument parsing rules, which is excellent for maintaining code quality and preventing regressions.
| fn parse_metadata_url(s: &str) -> Result<Url, String> { | ||
| let url = Url::parse(s).map_err(|e| e.to_string())?; | ||
| if url.as_str().len() > 2048 { | ||
| return Err("metadata URI cannot exceed 2048 bytes".to_string()); |
There was a problem hiding this comment.
where is this limit coming from?>
There was a problem hiding this comment.
Just something we found that should work for everyone, anything longer is probably a mistake and will likely start to not work with some systems.
There was a problem hiding this comment.
I'll add a comment
There was a problem hiding this comment.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a great refactoring that improves the CLI's usability by moving the --skip-metadata-validation flag to be a command-specific argument. The use of clap's validation features like requires and conflicts_with makes the CLI more robust and user-friendly. The code is well-organized, with the metadata-related arguments now cleanly separated into metadata.rs. The addition of comprehensive tests for the new argument constraints is also a big plus. I have one minor suggestion regarding a small redundancy in validation logic, but overall this is an excellent change.
Move --skip-metadata-validation from global flag to MetadataUriArgs, making it a command-specific flag that appears after the subcommand.
Changes:
Breaking change: --skip-metadata-validation must now appear after the subcommand instead of before it.
I think it's fine to make this breaking change now instead of doing it in a backwards compatible way. Only few people have used the CLI and we haven't built anything on top of this.