Skip to content

fix(media): guard SynchronizedMedia.frameDomain before reading frameRate - #397

Open
Mrxuba wants to merge 1 commit into
hypit-ai:mainfrom
Mrxuba:fix/synchronized-media-frame-domain-guard
Open

Mrxuba wants to merge 1 commit into
hypit-ai:mainfrom
Mrxuba:fix/synchronized-media-frame-domain-guard

Conversation

@Mrxuba

@Mrxuba Mrxuba commented Oct 16, 2026

Copy link
Copy Markdown

What

verifySynchronizedMedia dereferenced item.frameDomain.frameRate (and
item.frameDomain.frameCount) right after confirming only that the top-level
value is an object. When frameDomain is missing or is not an object, that
threw a bare TypeError: Cannot read properties of undefined (reading 'frameRate')
instead of a stated validation error.

This is the crash reported in #388, where reading an older / hand-edited
result.json whose SynchronizedMedia lacks a well-formed frameDomain
fails with exactly that message (@hypit/media@1#SynchronizedMedia ... Cannot read properties of undefined (reading 'frameRate')).

Fix

Add the same object() guard the sibling verifiers (verifyTimelineVisual,
verifyMuxedMedia, verifyRational, ...) already use, so a malformed frame
domain is reported as SynchronizedMedia.frameDomain must be an object.

   const item = object(value, "SynchronizedMedia") as unknown as SynchronizedMedia;
+  object(item.frameDomain, "SynchronizedMedia.frameDomain");
   verifyRational(item.frameDomain.frameRate, "SynchronizedMedia.frameDomain.frameRate");

Scope

This addresses only the unguarded frameRate crash from #388 (turning it into
a diagnosable validation error). It does not claim to make the bundled archive
replay end-to-end — that report also involves missing source.id / run.id
fields in the archived result, which are separate.

Tests

Adds packages/media/test/identity.test.ts:

  • a well-formed SynchronizedMedia still verifies;
  • a missing frameDomain and non-object frameDomain now throw the stated error.

pnpm --filter @hypit/media test (12 tests) and pnpm check both pass.

verifySynchronizedMedia dereferenced item.frameDomain.frameRate (and
.frameCount) right after confirming only that the top-level value is an
object. When frameDomain is missing or not an object it threw a bare
"Cannot read properties of undefined (reading 'frameRate')" TypeError
instead of a stated validation error. That is what surfaces when an
older or hand-edited result.json is read (see hypit-ai#388).

Add the same object() guard the sibling verifiers already use so a
malformed frame domain is reported as
"SynchronizedMedia.frameDomain must be an object".

Adds packages/media/test/identity.test.ts covering a well-formed value
and missing / non-object frame domains.

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.

1 participant