fix: guard Synchronization construction when no timecode axis is present#214
Open
rocketmark wants to merge 6 commits into
Open
fix: guard Synchronization construction when no timecode axis is present#214rocketmark wants to merge 6 commits into
rocketmark wants to merge 6 commits into
Conversation
jamesmosys
approved these changes
May 21, 2026
rocketmark
force-pushed
the
upstream-pr/fix-f4-sync-frequency-none
branch
from
May 21, 2026 13:38
91a6c77 to
81e5a26
Compare
Contributor
Author
|
Force pushed to resolve the branch conflicts. The change here doesn't conflict with the other changes. |
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.
Summary
get_tracking_frame()inmosys/f4.pyunconditionally constructsSynchronization(frequency=frequency)at the end of every frame.frequencydefaults to
Noneand is only set when a timecode axis (0xF8) appears inthe packet.
Synchronization.frequencyis typed asStrictlyPositiveRational,which does not accept
None, so the constructor raises a Pydantic validationerror and crashes the parser.
Demonstration
BEFORE:
F4PacketParser.get_tracking_frame()on any packet with no timecodeaxis raises a Pydantic
ValidationErroronSynchronization(frequency=None)AFTER:
returns a valid frame with
timing_synchronizationunset (None)Impact
Any F4 packet that omits the timecode axis (
FIELD_ID_TIMECODE,0xF8)causes
get_tracking_frame()to raise, aborting frame parsing. Callersreceive an unhandled exception rather than a partial frame.
Change
mosys/f4.py: wrap theSynchronizationconstruction andframe.timing_synchronizationassignment in aif frequency is not Noneguard so they are only executed when a timecode axis was present in the
packet. Four-line change.
test_mosys_reader.py: addtest_no_timecode_axis_does_not_crash— a unittest using a hand-crafted minimal packet with no timecode axis. Verifies the
parser returns a valid frame with
timing_synchronizationunset.Found via
Hypothesis-based property testing against a synthetic F4 packet generator.
Packets containing only the minimum required axes triggered the crash
immediately on the first generated example.