-
Notifications
You must be signed in to change notification settings - Fork 653
fix(meta): unify validation logic for system parameters #22289
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
Conversation
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 refactors and centralizes validation for system parameters by renaming existing macros/traits, introducing a new “validate all” macro for initialization, and integrating it into the controller initialization path.
- Renamed
impl_default_validation_on_set
→impl_default_validation
andValidateOnSet
→Validate
, and moved immutability checks intoset_system_param
- Added
impl_validate_all_params
macro to validate all parameters (including immutable ones) during initialization - Integrated
validate_init_system_params
inSystemParamsController
and added atest_init
unit test
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/common/src/system_param/mod.rs | Renamed validation macro/trait, updated impl_set_system_param to enforce immutability, added impl_validate_all_params and its tests |
src/meta/src/controller/system_param.rs | Imported and invoked validate_init_system_params after missing-param checks in initialization |
Comments suppressed due to low confidence (2)
src/common/src/system_param/mod.rs:404
- Add a doc comment explaining when to use
validate_init_system_params
(e.g., it should be called once on initialization) and how it differs from per‐param validation during updates.
pub fn validate_init_system_params(params: &PbSystemParams) -> Result<()> {
src/common/src/system_param/mod.rs:536
- The
test_init
function only coversbarrier_interval_ms
. Consider adding cases for other parameter types (e.g., strings, booleans) and edge values to ensure comprehensive coverage.
fn test_init() {
17ed105
to
849d738
Compare
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.
Rest LGTM.
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.
LGTM
What's changed and what's your intention?
This PR enhances system parameter validation by introducing checks for initial parameter values at startup.
The validation logic is now shared between parameter initialization and runtime updates, ensuring consistent rule enforcement for all parameters, regardless of their mutability.
Checklist
Documentation
Release note