refactor(msgpack): typed error for check_msgpack_structure (LAB-6496) - #89
Conversation
check_msgpack_structure returned a bare String, which does not implement
std::error::Error and was the crate's only public error outside thiserror.
Changing the signature after 0.7.0 publishes would be a semver break, so it
lands before the release.
MsgpackStructureError is opaque (private field, no kind()): no consumer
branches on the reason, and an accessor can be added later without a break.
Display is the unchanged bare reason, so decode_envelope's
'decode pre-scan: {what}' messages stay byte-identical.
Also: the allocation doc now states the true bound,
min(max_depth, bytes.len()) u64s; the module doc stops claiming SDK
bindings already call the walk; MAX_DEPTH moves into decode_envelope so it
inherits that fn's cfg.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: cachekit-io/cachekit-core/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe MessagePack structural pre-scan now returns a public ChangesMessagePack structural pre-scan
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The public error contract and existing decode message are preserved; no concrete merge-blocking risk remains. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The typed error changes how callers handle validation failures without changing the reviewed input controls, decoding order, or execution authority. No material security risk introduced or worsened by this change was identified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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 |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Summary
This PR replaces the
Stringerror returned bycheck_msgpack_structurewith a dedicated error type,MsgpackStructureError. It also corrects some documentation.Public API changes
check_msgpack_structure(bytes: &[u8], max_depth: usize)Result<(), String>toResult<(), MsgpackStructureError>.cachekit_core::MsgpackStructureError, re-exported fromlib.rsalongside the function.Stringfield, so downstream code cannot construct it or destructure it.Debug,Clone,PartialEq,Eqandthiserror::Error.Display(#[error("{0}")]) is the bare rejection reason with no prefix, for examplenests deeper than 100 levels.Behavioral compatibility
reject()helper.ByteStorage::retrievestill formatsdecode pre-scan: {what}throughDisplay, soByteStorageError::DeserializationFailedmessages are identical.Err(String)must switch to.to_string()or.unwrap_err().to_string(), as the updated doctests do.Internal changes
MAX_DEPTH = 100moves from a module-levelconstintodecode_envelope. This removes the duplicated#[cfg(all(feature = "compression", feature = "checksum", feature = "messagepack"))].the_error_is_a_std_error, checks at compile time that the type isstd::error::Error + Send + Sync + 'static.check()maps the error toString, so existing assertions stay unchanged.Documentation
min(max_depth, bytes.len())u64s. It no longer says "nothing proportional to the input".MsgpackStructureErrorand describe its prefix-freeDisplay.