Repository navigation
fix(cli): reject bad keyframes --shot --samples, --from and --to values as usage errors - #9057
Merged
jrusso1020 merged 3 commits intoNov 29, 2026
Conversation
…es as usage errors Closes heygen-com#9056 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs heygen-com#9056 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Refs heygen-com#9056 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jrusso1020
approved these changes
Nov 29, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Approve at abcfd4ff. Thanks for this, Dean. It's a clean, well-scoped fix, and the PR description made it easy to check.
What I checked
- Behaviour. With the built CLI,
--samples abc,--samples 0,--from -1and--to Infinityeach exit 2 and write no PNG. With--json, the output is{"ok":false,"error":{"code":"usage_error",…}}.--samples 12 --from 0.5 --to 1.5goes on to the normal animated-element check and exits 0, as before. - The tests guard the fix.
keyframes.test.tspasses locally (54/54). With the oldnum()parsing put back for the three flags, the 12 new rejection tests fail, so they would catch a regression. - Same behaviour for valid values. Reusing
parsePositiveIntegerArgwithmax: 60matches the existingMath.max(1, Math.min(60, …))clamp inmotionShot.ts, so every value that now passes renders exactly as before. Rejecting""inshotSecondsis a good catch, sinceNumber("")is 0. - Order. Parsing the flags at the top of
runOnionShotmeans a bad value is reported before the animated-element check and before any browser starts. Passing the parsed options intocaptureOnionShotkeeps a single parse. - The help text and the docs table both say 1 to 60. The commits are signed, CI is green, and the branch merges cleanly with current
main.
Optional, not for this PR
--from 2 --to 1 (an inverted range) is still accepted. If that is worth a usage error too, it would make a nice small follow-up.
Need ✅ (silent fallbacks hid bad input) · Size ✅ · Reuse ✅ (the shared integer-flag helper) · Simpler ✅ · Structure ✅
Risk: low. Only invalid values change behaviour. Valid ones take the same path as before.
— Rames
5 of 6 tasks
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.
What
hyperframes keyframes --shotnow rejects a bad--samples,--fromor--toas a usage error (exit 2) instead of quietly swapping it for something else.Why
All three flags went through the
num()helper inkeyframes.ts, which turns anything that isn't a number intonull.captureMotionPathShotthen clamped samples to 1 through 60. On main, with a small project that has one tween, every one of these printed "onion-skin screenshot saved" and exited 0.--samples abcused the default of 9.--samples 0used 1, and--samples 500used 60.--from abc --to xyzwere ignored, so the whole timeline was sampled.Related work
Fixes #9056. Same pattern as #7672 (
check) and #7909 (billing).How
--samplesuses the sharedparsePositiveIntegerArg(value, "--samples", { max: 60 })fromutils/integerArg.ts. The max matches the clamp already inmotionShot.ts, so every value that passes behaves exactly as before.--fromand--togo through a smallshotSecondscheck that accepts any finite number of 0 or more and throwsCliUsageErrorotherwise. An empty string is rejected too, sinceNumber("")is 0.runOnionShot, so a bad value is reported before the animated element guard runs and before any browser opens.captureOnionShotnow takes the parsed options instead of parsing them itself.num()is still used for the parsed keyframe values, so nothing else changes.--sampleshelp text and thedocs/packages/cli.mdxtable now say it takes 1 to 60.Test plan
keyframes.test.tsunderkeyframes --shot numeric flags. They coverabc,0,-3,2.5,61and""for--samples, andabc,-1,xyz,""andInfinityfor--fromand--to. Each must throw ausage_errorwith exit code 2. Another test runs the command with--samples abcon a project with no tweens and checks that it fails with the usage error and writes no PNG. Two more check that unset flags keep the defaults and valid values pass through.keyframes.test.tspass (cd packages/cli && npx vitest run src/commands/keyframes.test.ts).node dist/cli.js keyframes <project> --shot out.png ...).--samples abc,--samples 0,--samples 500,--from abc --to xyzand--from -1each print usage plus the error, exit 2, and write no PNG. With--jsonthe output is{"ok":false,"error":{"code":"usage_error",...}}.--samples 12 --from 0.5 --to 1.5still saves the screenshot and exits 0.🤖 Generated with Claude Code