Skip to content

Fix video_thumbnail_animation undefined frame size and zoom 0 - #90

Merged
11bit merged 1 commit into
mainfrom
fix-vta-frame-size-and-zoom-zero
Aug 21, 2026
Merged

Fix video_thumbnail_animation undefined frame size and zoom 0#90
11bit merged 1 commit into
mainfrom
fix-vta-frame-size-and-zoom-zero

Conversation

@11bit

@11bit 11bit commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Two defects found while auditing the codebase for the same class of bug as #89.

1. video_thumbnail_animation could emit a literal undefined

build({ vta: { step: 10, delay: 100, frames: 5 } })
// before: "vta:10:100:5:undefined:undefined"

frame_width and frame_height were guarded with if (… !== undefined) and then interpolated into the template unconditionally, so omitting them produced a malformed URL with no error.

The docs list both as required (Default: 0:0:0:0:0, no (optional) marker) and the VideoThumbnailAnimation type declares them as required numbers, so they are now validated like step, delay and frames. TypeScript callers were already prevented from hitting this; vanilla-JS callers now get video_thumbnail_animation.frame_width is not a number instead of a broken URL. video_thumbnail_tile already handled its five numeric arguments this way.

2. zoom: 0 was silently dropped

getOpt used options.zoom || options.z, so a zoom of 0 fell through to undefined, test() returned false, and the option vanished from the URL without an error. The guard was also { min: 0 }, which would have accepted 0 had it ever been reached — while the docs state zoom values "must be greater than 0".

Now getOpt uses ??, test checks !== undefined, and the guard uses minEqual, so 0 is rejected for zoom, zoom_x and zoom_y.

Test-visible change: the error message for non-positive zoom values changes from can't be less than 0 to can't be less or equal than 0. Two existing assertions were updated accordingly — the only existing tests this PR modifies.

Verification

  • tsc --noEmit clean, eslint src tests clean
  • vitest run → 97 files / 1100 tests passing (5 new: missing frame_width, missing frame_height, zoom: 0 rejected, zoom_x: 0 rejected, test({ zoom: 0 }) truthy)

Related

Follows #89. A third finding from the same audit — falsy values skipping validation in ~9 modules — is a mechanical sweep and comes in a separate PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G8Aa3xeVUCaxKtQJDzZhMo

`frame_width` and `frame_height` were guarded with `!== undefined` but
interpolated unconditionally, so omitting them produced
`vta:10:100:5:undefined:undefined`. Both are required by imgproxy and by
the option's type, so validate them like the other numeric arguments.

`zoom` used `||` in `getOpt`, so `zoom: 0` fell through to `undefined`
and the option was dropped without an error. imgproxy requires zoom
factors greater than 0, so reject 0 instead of ignoring it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G8Aa3xeVUCaxKtQJDzZhMo
@11bit
11bit merged commit c124469 into main Aug 21, 2026
1 check passed
@11bit
11bit deleted the fix-vta-frame-size-and-zoom-zero branch August 21, 2026 07:46
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