Skip to content

fix: key subject-path FromHexError by the meta hash verbatim - #261

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

fix: key subject-path FromHexError by the meta hash verbatim#261
thedavidmeister wants to merge 1 commit into
mainfrom
2026-08-25-issue-177

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Closes #177

The defect

MetaboardSubgraphClient::get_metabytes_by_subject built the FromHexError key as encode(&meta.meta_hash.0). meta_hash is a Bytes(String) already holding a 0x… hex string, so encode hex-encoded its UTF-8 bytes: 0xabcd rendered as 307861626364, a value that matches nothing in the subgraph. The by-hash path already carries the hash string verbatim.

The fix

metahash: meta.meta_hash.0.clone() — the string as it came off the wire, consistent with the by-hash path and with the "Error decoding metahash {metahash}" message the variant renders. The issue flagged the key format as a maintainer call; this is the reading that makes the rendered key mean what the message says it means, and the only one that keeps the two paths consistent.

QA

  • Discriminating tests: metaboard_client::tests::test_get_metabytes_by_subject_invalid_hex_meta — fails on base. The test predates this PR but deliberately pinned only the variant and non-emptiness of the key pending triage of get_metabytes_by_subject FromHexError identifies the meta by hex-of-ASCII of its hash string, not by the hash #177; it is tightened here to assert_eq!(metahash, "0xabcd"). Verified by reverting the one-line source change and re-running: test result: FAILED. 0 passed; 1 failed, with left: "307861626364", right: "0xabcd" — the issue's stated repro value exactly.
  • Mutations applied: crates/metaboard/src/metaboard_client.rs:121metahash: encode(&meta.meta_hash.0) (the pre-fix source) → killed by test_get_metabytes_by_subject_invalid_hex_meta (left: "307861626364"). Same line → metahash: subject.0.clone() (key by the subject instead of the meta's own hash — the other plausible reading) → killed by the same test (left: "0x7c", the mock's subject, vs the mock's metaHash 0xabcd). Both mutations were compiled and run.
  • Oracle: the issue's intent oracle, independent of the implementation — the variant's own #[error("Error decoding metahash {metahash}: {source}")] declares the field to be a metahash, and the sibling by-hash path (metahash: metahash.clone(), a 0x… string) fixes the format. The expected value 0xabcd is the metaHash the mocked subgraph response returns, read off the test fixture.
  • Category check: the issue asks one thing — the subject-path FromHexError key must identify the meta by its hash rather than by hex-of-ASCII of that hash string; covered. Checked every encode( call in the crate: no other site builds a field from an already-hex string (get_metabytes_by_hash and get_metaboard_addresses both carry their string verbatim).

Verification

cargo test -p rain-metaboard-subgraph --lib metaboard_client — 12 passed, 0 failed. cargo fmt --all --check and cargo clippy -p rain-metaboard-subgraph --all-targets -- -D warnings clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Corrected error reporting for invalid metadata hashes.
    • Error details now display the original hash value without redundant encoding, making invalid-hash issues clearer and easier to diagnose.

meta_hash is already a hex string; hex-encoding its UTF-8 bytes rendered
"0x1234" as "307831323334", matching nothing in the subgraph.

Closes #177

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5bbe0cfe-7402-4d53-946d-81886839b5c9

📥 Commits

Reviewing files that changed from the base of the PR and between 45ca96c and 605a91e.

📒 Files selected for processing (1)
  • crates/metaboard/src/metaboard_client.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

get_metabytes_by_subject now reports the offending meta hash verbatim in FromHexError. The related test documents this contract and asserts the exact key "0xabcd".

Changes

Meta hash error reporting

Layer / File(s) Summary
Use and validate the verbatim meta hash
crates/metaboard/src/metaboard_client.rs
The subject lookup stops double-encoding the meta hash. The test documentation and assertion verify the exact metahash value "0xabcd".

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 605a9

The change makes subject-based decoding errors identify the returned metadata hash verbatim, with targeted tests and standard checks passing; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: using the meta hash verbatim for the subject-path FromHexError key.
Linked Issues check ✅ Passed The changes satisfy issue #177 by replacing double-encoding with the original meta hash string and by asserting the exact expected key in the test.
Out of Scope Changes check ✅ Passed The implementation, test update, and documentation change are directly related to correcting the FromHexError key. No unrelated changes are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-08-25-issue-177

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.97.1)

Clippy execution timed out


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.

get_metabytes_by_subject FromHexError identifies the meta by hex-of-ASCII of its hash string, not by the hash

1 participant