fix(cli): gate authoring-meta-v2 normalize on an abi decode - #263
Open
thedavidmeister wants to merge 1 commit into
Open
fix(cli): gate authoring-meta-v2 normalize on an abi decode#263thedavidmeister wants to merge 1 commit into
thedavidmeister wants to merge 1 commit into
Conversation
AuthoringMetaV2 fell through the pure-bytes default arm, so `validate --meta authoring-meta-v2` reported every byte string valid, including bytes that can never abi decode as AuthoringMetaV2Sol[]. Closes #174 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 49 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #174.
What was wrong
KnownMeta::AuthoringMetaV2fell throughnormalize's default arm, whose comment claims the rest of the meta types are "only pure bytes". v2 is not pure bytes:AuthoringMetaV2Sol { bytes32 word; string description; }[]is a concrete abi encoding with anabi_decodein this crate. Becausevalidatetreats a successfulnormalizeas the validity verdict,rain-metadata validate --meta authoring-meta-v2 <any bytes>reported valid — the asymmetry withauthoring-meta-v1, which abi-decodes or json-parses and validates.The change
normalizegets anAuthoringMetaV2arm that gates onAuthoringMetaV2::abi_decodeand passes the input through unchanged. This crate has no v2 encoder and v2 payloads are abi encoded onchain, so the input is its own normal form and validation is decodability; a decode failure surfaces asError::InvalidInputcarrying the decode error.build, the othernormalizecaller, gets the same gate.The gate inherits the word utf8 requirement already in
abi_decode. It deliberately does NOT apply a word grammar — that is #168 / #257, which adds an opt-inabi_decode_validateand leavesabi_decodelenient because published v2 metas are immutable. That PR touches onlytypes/authoring/v2.rs, so there is no overlap with this one; if it lands and the grammar is wanted at this level too, this arm is the one call to switch.QA
meta::normalize::tests::test_normalize_authoring_meta_v2_rejects_arbitrary_bytes,meta::normalize::tests::test_normalize_authoring_meta_v2_rejects_non_utf8_word,cli::validate::tests::test_validate_err_for_arbitrary_authoring_meta_v2— each fails on base, verified by deleting the newKnownMeta::AuthoringMetaV2arm from the tree so v2 falls back to the passthrough and rerunning the filtered suite:test result: FAILED. 2 passed; 3 failed.test_normalize_authoring_meta_v2_abi_passthroughis a guard, not discriminating: it passes with and without the arm, pinning that a valid v2 payload is still returned byte identically.crates/cli/src/meta/normalize.rs, the wholeKnownMeta::AuthoringMetaV2 => { ... }arm -> deleted, so v2 falls through to_ => data.to_vec()(exactly the base behaviour the issue reports) -> killed by all three discriminating tests above.normalize's doc ("performs validation on those that need validation"), the default arm's "only pure bytes" claim, and the abi type declared incrates/cli/src/meta/types/authoring/v2.rs. Expected verdicts come from that encoding, not from the implementation:0xdeadand[]cannot be an abi encodedAuthoringMetaV2Sol[]so they must be rejected; bytes built asAuthoringMetaV2Sol[]must be accepted unchanged;0xc328...in the word slot is not utf8 before its first NUL so it must be rejected.0xdeadis the issue's own verified repro.AuthoringMetaV2decode gate on the default arm, or a doc note if v2 validation is deliberately out of scope; covered, with the gate. Its "may or may not apply to other structured entries (e.g.ExpressionDeployerV2BytecodeV1)" is deliberately not covered: the issue names v2 as the clear-cut one because its codec lives in this crate, and there is no codec here for that bytecode meta to gate on.Tests
test_normalize_authoring_meta_v2_abi_passthrough— a decodable payload is valid and byte identical out.test_normalize_authoring_meta_v2_rejects_arbitrary_bytes—0xdeadand[]are rejected, the issue's repro.test_normalize_authoring_meta_v2_rejects_non_utf8_word— abi shaped bytes with a non-utf8 word are rejected.test_validate_err_for_arbitrary_authoring_meta_v2— the CLI verdict itself.Local:
cargo test -p rain-metadata --lib -- normalize validate authoring62 passed 0 failed;cargo clippy -p rain-metadata --all-targetsandcargo fmt --all --checkclean. The full suite was not run locally, by instruction.🤖 Generated with Claude Code