Skip to content

fix(blob): reject unsupported formats during unpack - #1742

Open
godara-alt wants to merge 2 commits into
datajoint:masterfrom
godara-alt:fix/1703-clean-upstream
Open

godara-alt wants to merge 2 commits into
datajoint:masterfrom
godara-alt:fix/1703-clean-upstream

Conversation

@godara-alt

@godara-alt godara-alt commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1703.

Fix blob.unpack silently returning None when encountering an unknown or unsupported blob serialization format.

The decoder now raises a descriptive DataJointError for invalid formats while preserving the existing behavior for legitimately serialized None values.

Root Cause

The existing blob decoder only processed recognized mYm and dj0 serialization headers.

When an unrecognized header was encountered, execution could fall through without raising an error and implicitly return None.

This made malformed or unsupported serialized data indistinguishable from a valid serialized None value.

Changes

  • Validate the complete mYm\0 or dj0\0 serialization header before decoding.

  • Raise DataJointError when an unsupported blob format is encountered.

  • Add regression tests for empty, malformed, truncated-header, and unsupported payloads.

  • Verify that unknown formats inside compressed payloads are rejected.

  • Cover PostgreSQL-style memoryview inputs.

  • Verify that BlobCodec.decode correctly propagates decoding errors.

  • Preserve valid serialized None behavior.

  • Synchronize the branch with upstream master while retaining upstream character-array serialization improvements.

Testing and Verification

Latest commit: d7f39dc63c8fc1fbd0a34482310fd92e0593d378

The branch has been synchronized with the latest upstream master, and GitHub confirms there are no merge conflicts.

Check | Result -- | -- Lint and formatting | Passed Linux unit tests | Passed Windows unit tests (Python 3.10, 3.14, 3.15) | Passed MySQL integration tests (6 configurations) | Passed Minimum dependency versions (Python 3.10) | Passed

Final Result: All 12 upstream GitHub Actions test and lint jobs passed, with zero failures and zero pending checks.

The additional vulnerability-analysis check completed with a neutral result.

GitHub confirms the PR is conflict-free (mergeable: true).

Scope

The final changes are limited to:

  • src/datajoint/blob.py

  • tests/unit/test_blob_decompression.py

No new dependencies or unrelated modifications were introduced.

The fix preserves compatibility with existing valid blob formats and maintains the expected error behavior for corrupted or unsupported serialization headers.

@dimitri-yatsenko dimitri-yatsenko added this to the v2.4 milestone Nov 23, 2026
Preserve unknown blob format validation and regression coverage alongside upstream character-array and other fixes.

This branch has not been deployed

No deployments
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.

Decoding a <blob> value in an unknown format returns None instead of raising an error

2 participants