Repository navigation
fix(hooks): reject nested hook arrays - #11051
Conversation
|
Caution Review failedAn error occurred during the review process. Please try again later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
503632e to
582c87c
Compare
Greptile SummaryThis PR fixes the hook configuration deserializer to reject arbitrarily nested arrays that are invalid per the JSON schema but were silently accepted by the runtime. It does so by introducing a new
Confidence Score: 5/5The change is a structural refactoring of a deserialization enum with no behavioral change for valid configs and a correct new rejection for nested arrays. The refactoring is minimal and self-contained within src/hooks.rs. The public into_hooks contract is unchanged, all existing tests are updated to the new constructor shape, and the new test exercises both the accepted flat case and two rejected nested cases. No external callers pattern-match on HookDef variants directly. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "test(hooks): clarify flat array assertio..." | Re-trigger Greptile |
a284b11 to
465b827
Compare
Summary
Why
The JSON schema permits either one hook item or one array of hook items, but the runtime represented arrays as
Vec<HookDef>. SinceHookDefitself included the array variant, runtime deserialization accepted arbitrarily nested arrays and recursively flattened them. This made configurations executable by mise even though schema-aware editors and validators rejected them.The runtime now models an outer definition separately from a non-array item, matching the schema's single-array-level contract.
Example
Nested arrays are now rejected:
Use one flat array instead:
Validation
mise x cargo -- cargo test hooks::tests --all-featuresmise run lint-fixmise run test:e2e e2e/config/test_hooks e2e/config/test_hooks_task_ref e2e/config/test_hooks_script_arraysSummary by CodeRabbit