Skip to content

fix: guard FizEncoders construction when no encoder axis is present#212

Open
rocketmark wants to merge 6 commits into
SMPTE:mainfrom
rocketmark:upstream-pr/fix-f4-fiz-encoders-none
Open

fix: guard FizEncoders construction when no encoder axis is present#212
rocketmark wants to merge 6 commits into
SMPTE:mainfrom
rocketmark:upstream-pr/fix-f4-fiz-encoders-none

Conversation

@rocketmark

@rocketmark rocketmark commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

get_tracking_frame() in mosys/f4.py unconditionally constructs
FizEncoders(focus, iris, zoom) at the end of every frame. When no FIZ
axis appears in the packet, all three values remain None and FizEncoders
raises ValueError: FizEncoders requires at least one of focus or iris or zoom,
crashing the parser.

Demonstration

BEFORE: F4PacketParser.get_tracking_frame() on any packet with no encoder axes
raises ValueError: FizEncoders requires at least one of focus or iris or zoom

AFTER:
returns a valid frame with lens_encoders unset (None)

Impact

Any F4 packet that omits FIZ encoder axes causes get_tracking_frame() to
raise, aborting frame parsing. Callers receive an unhandled exception rather
than a partial frame.

Change

mosys/f4.py: wrap the FizEncoders construction in a guard so it is only
executed when at least one of focus, iris, or zoom was decoded from the
packet. One-line change.

test_mosys_reader.py: add test_no_encoder_axes_does_not_crash — a unit test
using a hand-crafted minimal packet with no encoder axes. Verifies the parser
returns a valid frame with lens_encoders is None.

Found via

Hypothesis-based property testing against a synthetic F4 packet generator.
Packets containing only the minimum required axes (timecode + focal length)
triggered the crash immediately on the first generated example.

get_tracking_frame() unconditionally constructed FizEncoders(None, None, None)
when no FIZ axis appeared in the packet, causing ValueError. Guard the
construction so lens_encoders is only set when at least one encoder value
was decoded.

Adds a unit test with a hand-crafted packet containing no encoder axes.
@rocketmark
rocketmark force-pushed the upstream-pr/fix-f4-fiz-encoders-none branch from 04eb1d2 to e9b67d8 Compare May 21, 2026 13:37
@rocketmark

Copy link
Copy Markdown
Contributor Author

Force pushed to resolve the branch conflicts. The change here doesn't conflict with the other changes.

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.

2 participants