Skip to content

fix(jsonb): fetch deserializer payloads through the checked slice - #11759

Merged
Xuanwo merged 2 commits into
lance-format:mainfrom
LuciferYang:fix/jsonb-decode-checked-slices
Dec 2, 2026
Merged

Xuanwo merged 2 commits into
lance-format:mainfrom
LuciferYang:fix/jsonb-decode-checked-slices

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Closes #11758.

RawJsonb::new accepts any byte slice. The serde Deserializer in rust/lance-jsonb/src/core/de.rs read NUMBER, STRING, and EXTENSION payloads by indexing raw.data[start..end] directly, without checking that the range is in bounds. When the buffer is shorter than the JEntry length field declares — truncated or corrupt stored bytes — that indexing panics.

The three functions now fetch their payloads through RawJsonb::slice, which returns Err(Error::InvalidJsonb) when the range exceeds the buffer length. No semantic change for valid input.

How was this patch tested

test_truncated_payload_is_rejected encodes a string and a float, then deserialization is attempted for every truncation of the payload region. Each attempt must return Err(Error::InvalidJsonb) rather than panic.

🤖 Generated with Claude Opus

A NUMBER, STRING or EXTENSION payload whose JEntry length runs past the end of
  the buffer was indexed directly, so `from_raw_jsonb` panicked with a slice
  error on a truncated or corrupt value instead of returning `Err`. The payload
  is now read with `RawJsonb::slice`, which reports the malformed range.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added the bug Something isn't working label Dec 2, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The checked-slice approach fixes the reported truncation panic while preserving valid JSONB decoding. No blocking issues found.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
@Xuanwo
Xuanwo merged commit 50bb3b5 into lance-format:main Dec 2, 2026
42 checks passed
@LuciferYang

Copy link
Copy Markdown
Contributor Author

Thanks @Xuanwo

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

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: deserializing truncated JSONB payloads panics instead of returning an error

2 participants