Skip to content

fix(cli): emit valid JSON for filtered keyframes - #6228

Open
AksharP5 wants to merge 1 commit into
heygen-com:mainfrom
AksharP5:keyframes-json
Open

AksharP5 wants to merge 1 commit into
heygen-com:mainfrom
AksharP5:keyframes-json

Conversation

@AksharP5

Copy link
Copy Markdown
Contributor

What

keyframes --runtime css --json and --runtime anime --json now emit parseable JSON. Both commands were prefixing the JSON object with a human-readable notice, breaking scripts even though the CLI exited 0.

Why

Agents and scripts need to parse the complete stdout when they request --json.

With the issue's exact HTML and --runtime css --json or --runtime anime --json:

Result Before After
CLI exit code 0 0
JSON.parse(stdout) Unexpected token 'k', "keyframes:"... is not valid JSON Succeeds
Parsed filter and records Unreadable as JSON runtime: "css", one CSS keyframe; runtime: "anime", one Anime.js record
Human output without --json Static authoring notice Same notice

Related work

Fixes #6226.

Searched open and closed issues/PRs by symptom and notice path before implementation and publication. #5526 and #2374 cover static keyframe data and template extraction, #5959 concerns rendered image transforms, and #5534 is a release. None covers this output failure.

How

Move the existing notice after the JSON early return. Add command-level regression cases for CSS and Anime.js that parse every stdout log together, including the empty-result case. Document runtime-filtered JSON output in the CLI guide.

Test plan

  • Unit tests added/updated: both new cases fail on the baseline with the exact parser error; 41 focused keyframes tests pass with the fix.
  • Manual testing performed: built Node CLI, both runtime filters, full-stdout JSON parsing, and human notice preserved.
  • Full workspace build; CLI typecheck; CLI rebuild and affected tests/typecheck repeated after rebasing onto 3d45d1b037860afd42439a2b4ca7e0dc762448c3.
  • oxlint, oxfmt, comment-citation checks, comment-share check, and git diff --check.
  • Documentation updated in docs/developers/cli.mdx. Mintlify validation/broken-link commands were unavailable because mint is not installed; no software was installed for them.
  • Comments follow CONTRIBUTING.md "Comments". No comments added.

Validation ran on Linux x86_64, Node v26.11.1, Bun 1.4.1. The repository requests Bun 1.4.4; the commands passed without upgrading Bun. /tmp reached its user quota during setup, so builds and tests used a writable TMPDIR on the worktree filesystem.

@mintlify

mintlify Bot commented Oct 24, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 055fbf3.

Approve preview

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a clean fix. Moving the notice below the JSON early return is the right place for it, and the new test runs the real command and parses the whole of stdout, so it catches anything else that leaks in. I confirmed both cases fail on the old code with the same parser error and pass with the change.

One related thing you may want to fold in or leave for later: --shot runs before the JSON branch, so keyframes … --shot out.png --json still prints the screenshot lines (or the "no statically resolved animated element" message) as plain text to stdout instead of JSON (packages/cli/src/commands/keyframes.ts:1093, output at :857 and :883). It predates this PR and isn't what the issue reported, so it doesn't block this.

Verdict: APPROVE
Reasoning: The fix is minimal and correct, the regression test runs the real command and fails without the change, and all checks are green.

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.

keyframes --runtime css/anime --json prefixes stdout with text

2 participants