Conversation
…licated columnar decode (LAB-2736) ByteStorage.retrieve() flattened every corruption case (checksum mismatch, decompression bomb/failure, size mismatch) into the same PyValueError as "not a ByteStorage envelope at all", so AutoSerializer.deserialize() could not tell a genuinely corrupted cache entry from bytes that were legitimately written without an envelope (integrity checking off) - a checksum mismatch either fell through to a confusing "not decodable" error or, on the DataFrame/Series path, was duplicated into two near-identical retrieve+decode blocks with their own ad hoc error text. Add EnvelopeIntegrityError (rust/src/python_bindings.rs), a ValueError subclass raised for every ByteStorageError variant except DeserializationFailed (which stays a plain ValueError - the fall-through signal deserialize() depends on). AutoSerializer.deserialize() catches it specifically and re-raises as SerializationError without falling through. Collapse the DataFrame/Series metadata pre-branch and the verified-envelope branch onto the single _decode_columnar path, and drop the dead isinstance(data, dict) branches in _deserialize_dataframe/_deserialize_series now that no caller passes raw bytes. Expert-panel review caught a regression the collapse introduced: an entry written with integrity off and read by an integrity-on reader (same metadata routing to dataframe/series) fell through to the generic msgpack fallback and returned the raw wire dict instead of failing closed or reconstructing - fixed by routing that fallback through _decode_columnar too, with a regression test.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (5)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. WalkthroughThe change adds specialised envelope integrity errors, updates ChangesEnvelope integrity and columnar decoding
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant AutoSerializer
participant PyByteStorage
participant ByteStorage
participant ColumnarDecoder
AutoSerializer->>PyByteStorage: retrieve envelope
PyByteStorage->>ByteStorage: retrieve bytes
ByteStorage-->>PyByteStorage: payload or retrieval failure
PyByteStorage-->>AutoSerializer: payload or mapped exception
AutoSerializer->>ColumnarDecoder: decode verified DataFrame or Series payload
Merge Risk: 🔵 Low · up to A narrow class of previously supported direct MessagePack values may fail to deserialize when read with integrity checking enabled. This is bounded but should be tracked before relying on mixed integrity configurations. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description clearly explains the implementation changes, motivation, and tests. However, it does not follow the required template and omits the Type of Change, Security Checklist, Documentation Validation Checklist, Backward Compatibility, and Additional Notes sections. It also does not record the required test and security checklist results. Resolution Update the description to include every required template section. Select the applicable Type of Change options. Complete the security, documentation, testing, and backward compatibility checklists. State the motivation explicitly and record any additional reviewer context.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@kody start-review |
Resolve the LAB-3131 (#289) overlap in the columnar decode path: - src/cachekit/serializers/auto_serializer.py: both sides retired the dead isinstance(data, dict) preamble in _deserialize_dataframe/_deserialize_series; keep main's parameter naming and docstrings. The PR's deserialize() collapse and EnvelopeIntegrityError handling are unchanged. - tests/unit/test_auto_serializer_new_types.py: both sides adapted the four TestColumnarFallbackExtensionDtypes tests to the decoded-document contract; keep the PR's public serialize()/deserialize() round-trip, which routes through main's _decode_columnar.
|
Merged |
Resolve the LAB-304 (#264) overlap in src/cachekit/serializers/auto_serializer.py: one import-block hunk. The PR added EnvelopeIntegrityError to the ByteStorage import; main added the redact_error_for_log import used by the envelope-fallback debug log. Keep both (union). Main's redacted logger.debug call and the PR's deserialize() collapse auto-merged untouched.
|
Resolved |
Summary
This PR introduces a distinct exception type for
ByteStorage.retrieve()verification failures and consolidates duplicated columnar (DataFrame/Series) decode logic in theAutoSerializer.Changes
New
EnvelopeIntegrityErrorexception (Rust layer)EnvelopeIntegrityErrorexception (subclass ofValueError) in the Rust bindings, registered on the Python module with a corrected__module__so it remains picklable across processes.retrieve_error_to_pymapping function that translatesByteStorageErrorvariants into the Python exception taxonomy:DeserializationFailed(bytes that were never a ByteStorage envelope) → plainValueError, preserving the fall-through signal that callers rely on.EnvelopeIntegrityError, which must fail closed.Previously, both "not an envelope" and genuine corruption raised an indistinguishable
ValueError, so the deserializer could not reliably tell them apart.AutoSerializer.deserializebehaviorEnvelopeIntegrityErrorspecifically and re-raises it asSerializationError(fail-closed), rather than falling through to a plain-msgpack/NumPy re-parse of corrupt bytes.Collapsed duplicated columnar decode paths (LAB-2736)
dataframeandseriesbranches so that, when integrity checking is on, they share a single Rust-enveloperetrieve+_decode_columnarpath instead of a duplicated copy.dataframe/seriestype but no envelope was used (integrity off) or the envelope wasn't recognized (cross-config read), the bytes are still routed through_decode_columnarto reconstruct the proper DataFrame/Series — preventing a regression where the raw wire dict would be returned instead._deserialize_dataframeand_deserialize_seriesto accept already-unpacked documents, removing redundant internal msgpack unpacking.Tests
SerializationError, while plain msgpack written with integrity off still falls through and decodes correctly.serialize/deserializeround-trip (forcing the msgpack-columnar path) instead of calling internal helpers directly.Summary by CodeRabbit
Bug Fixes
Tests