fix: key subject-path FromHexError by the meta hash verbatim - #261
fix: key subject-path FromHexError by the meta hash verbatim#261thedavidmeister wants to merge 1 commit into
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. Walkthrough
ChangesMeta hash error reporting
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to 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)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Closes #177
The defect
MetaboardSubgraphClient::get_metabytes_by_subjectbuilt theFromHexErrorkey asencode(&meta.meta_hash.0).meta_hashis aBytes(String)already holding a0x…hex string, soencodehex-encoded its UTF-8 bytes:0xabcdrendered as307861626364, 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
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 toassert_eq!(metahash, "0xabcd"). Verified by reverting the one-line source change and re-running:test result: FAILED. 0 passed; 1 failed, withleft: "307861626364",right: "0xabcd"— the issue's stated repro value exactly.crates/metaboard/src/metaboard_client.rs:121→metahash: encode(&meta.meta_hash.0)(the pre-fix source) → killed bytest_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'smetaHash0xabcd). Both mutations were compiled and run.#[error("Error decoding metahash {metahash}: {source}")]declares the field to be a metahash, and the sibling by-hash path (metahash: metahash.clone(), a0x…string) fixes the format. The expected value0xabcdis themetaHashthe mocked subgraph response returns, read off the test fixture.FromHexErrorkey must identify the meta by its hash rather than by hex-of-ASCII of that hash string; covered. Checked everyencode(call in the crate: no other site builds a field from an already-hex string (get_metabytes_by_hashandget_metaboard_addressesboth carry their string verbatim).Verification
cargo test -p rain-metaboard-subgraph --lib metaboard_client— 12 passed, 0 failed.cargo fmt --all --checkandcargo clippy -p rain-metaboard-subgraph --all-targets -- -D warningsclean.🤖 Generated with Claude Code
Summary by CodeRabbit