Skip to content

fix(cli): batch renders accept PowerShell JSON files - #6605

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

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

Conversation

@AksharP5

Copy link
Copy Markdown
Contributor

What

Batch rendering rejects otherwise valid JSON saved with a UTF-8 BOM or as UTF-16LE with a BOM, including files written by Windows PowerShell. These files now render through the existing JSON decoder.

The complete input and setup are in #6604. On the same one-second composition, run:

node --import ../node_modules/tsx/dist/loader.mjs ../packages/cli/src/cli.ts render \
  --batch rows-utf8.json --output 'renders/{index}.mp4' \
  --fps 1 --workers 1 --json --quiet --strict-variables

Repeat with rows-utf16le.json; only that filename changes between the two encoding cases. Within each case the input bytes, composition, arguments, environment and browser are identical before and after.

Batch file Main 7e92aec5 This patch
UTF-8 with BOM Exit 1: Invalid JSON in --batch Exit 0: 1 completed, 0 failed
UTF-16LE with BOM Exit 1: Invalid JSON in --batch Exit 0: 1 completed, 0 failed

Both successful runs produce this projection of stdout (paths and timing fields omitted):

{"type":"batch-complete","total":1,"completed":1,"failed":0,"skipped":0,"variables":{"title":"Café"},"durationMs":1000}

FFprobe reports H.264, 320×180, one frame and 1.000000 seconds for each output. I decoded and inspected both frames: they show Café. An unmarked UTF-8 control also renders successfully.

Why

The batch reader decoded every file as UTF-8 and sent a leading BOM directly to JSON.parse. Other JSON flags already decode these PowerShell file formats.

Related work

Fixes #6604.

#5725 handles project configuration; #6580 handles HTML files; #6591 handles undefined injected readers for --variables-file. This change uses the existing decoder without changing that reader-selection logic.

How

Share the existing byte decoder with the batch-file reader. Keep JSON parsing and row validation unchanged. The regression reads real UTF-8 and UTF-16LE files, checks non-ASCII text and the output path, and preserves a U+FEFF inside a value.

Test plan

  • Unit tests added/updated: both new encoding cases fail on unmodified main and pass with the fix; all 68 focused batch/JSON/render-plan/execution tests pass.
  • Manual testing performed: identical-input CLI comparisons above, plus unmarked UTF-8 control, composition lint/check, FFprobe and frame inspection. Tested on Linux arm64, Node 24.22.1, Bun 1.4.4, Chromium 156.0.8078.47 and FFmpeg 7.0.2. Native Windows execution was not tested.
  • Full workspace build, rebuilt CLI, CLI typecheck, Oxlint/Oxfmt, normal Lefthook pre-commit and commit-msg gates, commitlint, comment citation and comment-share checks.
  • Wider CLI unit run: 5,802 passed, 7 skipped, 9 failed. All nine failures reproduce unchanged on unmodified main in the same environment: browser manager (4), download-stall process (2), archive extraction (2), and port PID inspection (1). A matched eight-file baseline/fix run removes only the two new encoding failures and introduces none.
  • Documentation updated with supported batch-file encodings. Mintlify validation and broken-link commands could not run because mint is not installed locally.
  • Comments follow CONTRIBUTING.md "Comments"; no comments added.

@mintlify

mintlify Bot commented Oct 28, 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 1145a3f.

Approve preview

@AksharP5

AksharP5 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Independent GPT-6 Astra high review of exact head 1145a3f7c641f3202d60c86bc3482f57cd742cb3 found no actionable introduced findings.

The reviewer independently passed 68 focused tests and 26 bounded base/head controls. Both BOM-marked batch formats fail on the base and succeed on this head, preserving Café, non-ASCII output paths and a literal U+FEFF inside a value. Inline JSON, stdin, custom string readers and reader selection retain their existing behavior. The related configuration, HTML and variables-file PRs address distinct boundaries.

Review validation reused the verified clean exact-head author checkout and its existing successful build. Native Windows, the broad suite and fresh video renders were not rerun by the reviewer. The author's matching render proof and baseline comparison remain in the PR description. All twelve required checks have passed at 1145a3f7c641f3202d60c86bc3482f57cd742cb3, with no failed or pending checks. Maintainer approval is still required; the independent review does not change GitHub's approval state. No merge performed.

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.

Batch rendering rejects JSON files saved with a byte order mark

1 participant