Skip to content

fix(media-use): escape the audio engine's summary and broken audio_meta.json errors - #8258

Merged
michaelwang11394 merged 1 commit into
mainfrom
michaelwang/secops-3103-media-use-audio-engine-prints
Nov 19, 2026
Merged

michaelwang11394 merged 1 commit into
mainfrom
michaelwang/secops-3103-media-use-audio-engine-prints

Conversation

@michaelwang11394

Copy link
Copy Markdown
Contributor

What

The media-use audio engine (skills/media-use/audio/scripts/audio.mjs) now escapes the last two places where it printed text from audio_meta.json raw.

  • The summary line that reports the voice count, bgm_provider and the number of sound effects goes through terminalText(), like the lines around it. With --only tts or --only sfx, bgm_provider and sfx are kept unchanged from the existing audio_meta.json, so they are project-file text.
  • openAudioMeta(outPath) runs inside a try. A malformed audio_meta.json now stops through die() with audio_meta.json at <path>: <message>, which escapes each line the same way wait-bgm.mjs does. It no longer reaches Node's default uncaught-error printer, which quoted bytes of the file raw.
  • Normal output prints exactly as before, and the files written are unchanged. The malformed case still exits with code 1.

Why

A project folder someone else made can put terminal control sequences in audio_meta.json. Printed raw, they can rewrite earlier output, set the window title or, on some terminals, write the clipboard. #8235 escaped the rest of these scripts' output; these two places were left.

Related work

Follows #8235, #8249 and #8013.

How

See What.

Visible change

A malformed audio_meta.json now prints a one-line error naming the file instead of Node's stack trace. Text with control characters shows as escapes such as \x1b. Ordinary output reads as before.

Test plan

  • Unit tests added/updated

  • Manual testing performed

  • Documentation updated (if applicable)

  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

  • fails without the fix: 3 new tests in skills/media-use/audio/scripts/audio.test.mjs fail on main:

    • --only tts with ESC and BEL in the kept bgm_provider and sfx values;
    • --only sfx with the same file;
    • a broken audio_meta.json holding ESC and BEL bytes.
      The first two also check that audio_meta.json is written unchanged. None of the tests use the network.
  • All tests in skills/media-use/audio/scripts/*.test.mjs pass. The media-use copy-parity check passes 4 of 4, and gen-skills-manifest --check, oxlint, oxfmt and the comment ratchet pass. skills-manifest.json changes only the media-use hash.

  • Manual: a normal --only sfx run prints the same stdout and writes the same audio_meta.json on main and on this branch.

  • Not changed: die() escapes each line but keeps real line breaks, like wait-bgm.mjs and the rest of fix(media-use): duck, cut, transcribe, dither and audio scripts print control characters as escapes #8235. So a line break inside the file's bytes still starts a new line. A valid but wrong-shape audio_meta.json (for example null) still crashes with a stack trace, but that trace holds no project bytes.

…n errors

The run summary now escapes the BGM provider and SFX count carried over
from audio_meta.json. A malformed audio_meta.json now stops the engine
through its usual error line, which escapes the file's bytes, instead of
an uncaught exception.

@jrusso1020 jrusso1020 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.

Approving at 76228f9.

  • Summary line: the line with bgm_provider and the sound-effect count now goes through terminalText(), like the lines around it. With --only tts or --only sfx, both values are carried over from audio_meta.json, so they're project-file text.
  • Malformed file: openAudioMeta now runs inside a try, and a malformed audio_meta.json exits through die() with audio_meta.json at <path>: <message>, escaped line by line as wait-bgm.mjs does. Node's default uncaught-error printer no longer runs on it.
  • Tests: audio.test.mjs passes 20/20 at this head. With audio.mjs put back to main and the tests kept, exactly the 3 new tests fail (17/20): --only tts, --only sfx, and the broken file. The first two also check audio_meta.json is written unchanged.

Non-blocking, as the body says: a valid but wrong-shape audio_meta.json (for example null) still ends in a stack trace. That trace holds no file bytes, but routing it through die() too would make every bad file end the same way.

Need: nothing.

@michaelwang11394
michaelwang11394 added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 4a11e46 Nov 19, 2026
62 checks passed
@michaelwang11394
michaelwang11394 deleted the michaelwang/secops-3103-media-use-audio-engine-prints branch November 19, 2026 22:52
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.

2 participants