Skip to content

fix(cli): gate authoring-meta-v2 normalize on an abi decode - #263

Open
thedavidmeister wants to merge 1 commit into
mainfrom
2026-08-25-issue-174
Open

fix(cli): gate authoring-meta-v2 normalize on an abi decode#263
thedavidmeister wants to merge 1 commit into
mainfrom
2026-08-25-issue-174

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Closes #174.

What was wrong

KnownMeta::AuthoringMetaV2 fell through normalize'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 an abi_decode in this crate. Because validate treats a successful normalize as the validity verdict, rain-metadata validate --meta authoring-meta-v2 <any bytes> reported valid — the asymmetry with authoring-meta-v1, which abi-decodes or json-parses and validates.

The change

normalize gets an AuthoringMetaV2 arm that gates on AuthoringMetaV2::abi_decode and 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 as Error::InvalidInput carrying the decode error. build, the other normalize caller, 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-in abi_decode_validate and leaves abi_decode lenient because published v2 metas are immutable. That PR touches only types/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

  • Discriminating tests: 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 new KnownMeta::AuthoringMetaV2 arm 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_passthrough is a guard, not discriminating: it passes with and without the arm, pinning that a valid v2 payload is still returned byte identically.
  • Mutations applied: crates/cli/src/meta/normalize.rs, the whole KnownMeta::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.
  • Oracle: the issue's intent oracle, read independently of this code — normalize's doc ("performs validation on those that need validation"), the default arm's "only pure bytes" claim, and the abi type declared in crates/cli/src/meta/types/authoring/v2.rs. Expected verdicts come from that encoding, not from the implementation: 0xdead and [] cannot be an abi encoded AuthoringMetaV2Sol[] so they must be rejected; bytes built as AuthoringMetaV2Sol[] must be accepted unchanged; 0xc328... in the word slot is not utf8 before its first NUL so it must be rejected. 0xdead is the issue's own verified repro.
  • Category check: the issue asks for one thing — an AuthoringMetaV2 decode 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_bytes0xdead and [] 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 authoring 62 passed 0 failed; cargo clippy -p rain-metadata --all-targets and cargo fmt --all --check clean. The full suite was not run locally, by instruction.

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 49 minutes.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b5f2b341-55f2-4f4e-8429-35fc316c3f8e

📥 Commits

Reviewing files that changed from the base of the PR and between 45ca96c and 4bcc15e.

📒 Files selected for processing (2)
  • crates/cli/src/cli/validate.rs
  • crates/cli/src/meta/normalize.rs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KnownMeta::AuthoringMetaV2 normalize/validate accepts arbitrary bytes through the pure-bytes passthrough arm

1 participant