Skip to content

Bugfix/binary parameter truncation fix#247

Merged
medley56 merged 1 commit intorelease/6.1from
bugfix/BinaryParameter-Truncation-fix
Apr 2, 2026
Merged

Bugfix/binary parameter truncation fix#247
medley56 merged 1 commit intorelease/6.1from
bugfix/BinaryParameter-Truncation-fix

Conversation

@medley56
Copy link
Copy Markdown
Member

@medley56 medley56 commented Apr 1, 2026

Summary

This prepares for a patch release 6.1.2 with a fix for binary parameter truncation when the binary blob is longer than 4 bytes.

Fixes #246.

Approach

The only way np.asarray will correctly identify the required size for a binary blob is to pass in a bytes object (not a bytes subclass like BinaryParameter). After much digging and many attempts at changing the MRO of BinaryParameter, it appears the only fix is to conditionally cast BinaryParameter objects to bytes objects before attempting to create a numpy array.

Other Considered Option

One option that did work was to change the parent type of BinaryParameter from bytes to np.bytes_, which correctly registers the class as a subclass of np.bytes_ and results in numpy correctly determining the size of the bytes object.

However, this would require making numpy a core dependency of Space Packet Parser, something we have long worked to avoid.

Performance Impact

This conditional recreation of a bytes object from BinaryParameter in create_dataset does impact performance when creating an xarray Dataset from packets containing BinaryParameter objects. The impact is due to creating a second, immutable copy of every BinaryParameter object (one at a time).

There should be almost no memory impact but there will be a timing impact due to the conditional check and the creation of new bytes objects. This impact should only matter for packets that include binary blobs though.

@medley56 medley56 self-assigned this Apr 1, 2026
Copilot AI review requested due to automatic review settings April 1, 2026 16:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes binary parameter truncation in xarr.create_dataset when BinaryParameter values exceed 4 bytes, preparing for patch release 6.1.2 (fixes #246).

Changes:

  • Convert common.BinaryParameter instances to plain bytes before passing values to NumPy, preventing truncation during np.asarray dtype sizing.
  • Add a unit test to ensure binary parameter byte-width is preserved in the resulting xarray.Dataset.
  • Bump several GitHub Actions workflow dependencies and adjust the GitHub Release creation step to use a safer argument array pattern.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
space_packet_parser/xarr.py Casts BinaryParameter to bytes prior to NumPy array creation to prevent truncation.
tests/unit/test_xarr.py Adds regression test asserting 8-byte binary fields remain 8 bytes and untruncated in datasets.
.gitignore Ignores node_modules.
.github/workflows/release.yml Updates artifact download action version and refactors gh release create invocation.
.github/workflows/ci.yml Updates Codecov GitHub Action version.
.github/workflows/_build.yml Updates artifact upload action version.

@medley56 medley56 linked an issue Apr 2, 2026 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.85%. Comparing base (84d2a76) to head (0660a8f).
⚠️ Report is 1 commits behind head on release/6.1.

Additional details and impacted files
@@               Coverage Diff               @@
##           release/6.1     #247      +/-   ##
===============================================
+ Coverage        94.82%   94.85%   +0.02%     
===============================================
  Files               48       48              
  Lines             3868     3885      +17     
===============================================
+ Hits              3668     3685      +17     
  Misses             200      200              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@medley56 medley56 added bug Something isn't working cibuild Label to control artifact builds during CI labels Apr 2, 2026
- Add conditional logic in create_dataset to change BinaryParameter
  objects to bytes objects when creating numpy arrays of byte strings
- Add a focused regression test in test_xarr.py:181
- Modify workflow run conditions for tests
- Bump version to 6.1.2
@medley56 medley56 force-pushed the bugfix/BinaryParameter-Truncation-fix branch from bdf094a to 0660a8f Compare April 2, 2026 21:30
@medley56 medley56 merged commit e6dcf0c into release/6.1 Apr 2, 2026
22 checks passed
@medley56 medley56 deleted the bugfix/BinaryParameter-Truncation-fix branch April 2, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cibuild Label to control artifact builds during CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BinaryParameters longer than 4 bytes are truncated by create_dataset

3 participants