Repository navigation
Warn when _parse_ccsds_head is given more than 10 bytes - #73
Merged
Merged
Conversation
read_file_sc passed the rest of the file to _parse_ccsds_head to read the first header. Pass only the header bytes instead, and warn when more than 10 bytes are given so that similar slicing mistakes are visible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
namurphy
commented
Oct 7, 2026
Member
Author
|
I don't think it's normal behavior for the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_parse_ccsds_headdecodes only the first 10 bytes it is given and silently ignores the rest. This PR makes it issue aUserWarningwhen it gets more than 10 bytes, because a longer input probably means the caller sliced the bytes incorrectly.read_file_scwas the only caller that passed more than 10 bytes: it passed the rest of the file (bytestr, orbytestr[17:]for PTP files) to read the first header. It now passesbytestr[:10]orbytestr[17:27], so spacecraft conversions don't raise the new warning. The other callers,_read_bytestrand_wrapper_status, already pass slices of at most 10 bytes.Other changes:
Warnssection to the docstring of_parse_ccsds_head.SIM108suppression inread_file_scthat ruff now reports as unused.test_parse_ccsds_head_ignores_extra_byteswithtest_parse_ccsds_head_warns_about_extra_bytes, which checks that the warning is raised and that the extra bytes still don't change the result.No test covers
read_file_scbecause there is no spacecraft test data, so the change to its slicing is untested. If the first header is cut short, the slice raises the sameValueErroras before, whichread_file_scalready catches.🤖 Generated with Claude Code