Repository navigation
fix(timeline): refuse colors that are not colors before they reach FFmpeg - #72
Merged
Merged
Conversation
…mpeg A color clip's color and the canvas background went into the filter graph unquoted (`color=c=…`, `pad=…:color=…`), so a value like `black[p];movie=/path[m];[p][m]overlay` added filters: it read a file outside the workspace into the export, and `metadata=…:file=` created one. Validate colors where they enter (the add_color verb for MCP and the UI, and `clip timeline new --background` / `add-color --color`), and have the compiler refuse a stored value that is not a color with a CompileError. Accepted: FFmpeg color names in any case, #rrggbb[aa], 0xrrggbb[aa], with an optional @Alpha. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 16, 2026
|
🎉 This PR is included in version 0.5.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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
src/timeline/color.ts:isColor,invalidColorMessageand a ZodColorSchema. It accepts FFmpeg's 140 color names (any case), hex#rrggbb[aa]/0xrrggbb[aa](barerrggbb[aa]too, which FFmpeg also reads), and an optional@alphafrom 0 to 1 or0x00–0xff. Everything else is refused with:"<value>" is not a color. Use a color name like black or white, or hex like #ffcc00, optionally with @0.5 for opacity.add_colorverb (EditableVerbSchemafor MCPtimeline_edit,CompositionVerbSchemafor theclip uiverbs route)clip timeline new --backgroundandclip timeline add-color --color. Both throw before writing, so a bad--backgroundno longer replaces the current document.quoteColornow throws aCompileError(Color clip "<id>" color …/Canvas background …) instead of emitting the value. It runs during plan building, so nothing reaches FFmpeg, andcheckExportablereports it as a blocker intimeline show/timeline_check.docs/backlog/timeline-color-validation.md.Not changed, on purpose:
CompositionSchemaandCompositionOpSchemastayz.string(). A stored document or op log with a bad value still loads, and export refuses it.fontcolor,boxcolor) already go throughquoteFilterArg. A bad text color fails inside drawtext; it can't add filters. I checked the single-file tools too:add_title_carduses a strict regex, andadd_text/chroma_keyquote their colors. No gap there.Why
quoteColorpassed any non-#string straight into the graph in two places:pad=…:color=<canvas background>in every clip's framing chain-f lavfi -i color=c=<color>:s=WxH:r=Ffor color clips (and the canvas background behind text clips)The hypothesis holds. Checked with the bundled
ffmpeg-static6.0 (FFmpeg 7.1.1 has the same color table), using the exact arg arrays the compiler emitted before this change:black[p];movie=<file outside the workspace>[m];[p][m]overlayrendered that file into the export. The test image was solid#12ab34: the exported pixel read0fa92f, against000000for a plainblackbackground. The color-clip input works the same way. The trailing:s=…:r=…gets in the way, but an unterminated quote in a finalmetadata=…:value='absorbs it, and the export showed the outside file again.black,metadata=mode=print:file=<path>created that file.So any caller that can set a color could break non-negotiable #3: an MCP client (
add_color), the browser UI (verbs route), the CLI flags, or any stored document (hand edit, older version, or the library APIcolorClip/setCanvas).How to test
pnpm test -- tests/timeline-color.test.tsCI=true pnpm exec vitest run tests/integration/timeline-color.test.tstests/timeline-color.test.ts(unit, no FFmpeg):add_colorrefused through both verb schemascolor=c=0x12ab34:s=1920x1080:r=30andpad=…:color=Navy@0.5CompileErrorfor stored bad card colors and backgrounds, and thecheckExportableblockertests/integration/timeline-color.test.ts(real FFmpeg, CI only):pad=the way the old compiler placed ittimeline_editrefusing ittimeline_exportrefusing a stored hostile background with no output and no file written#12ab34card renders as that colorChecks
pnpm lint: pass, 0 errors. The 7 warnings are already onmain, intests/speed.test.tsandtests/transition.test.ts.pnpm type-check: pass.pnpm test: 857 passed, 28 skipped.pnpm build: pass.feat/shortsto ship with the shorts release. This branch merged intofeat/shorts(ata2b0895) with no conflicts, and the merged tree passes: lint 0 errors, type-check, test (902 passed, 29 skipped), build. The shorts code adds no new place a color reaches FFmpeg.CI=true vitest run tests/integration, locally on macOS with real FFmpeg: 28 passed, 4 skipped. This ran before the Codex fix; the new integration test was rerun after it and passes.compile.ts, the 3 compiler tests fail, and the integration test fails because the export runs.codex review, gpt-6.1-sol, on the full change): gate PASS with 1 finding.\d+\.?\d*backtracked quadratically on a long malformed@alpha, so a large MCP/UI input could stall the event loop. Fixed with the non-overlapping\d+(?:\.\d*)?and the linear-time regression test above. Codex was not rerun after the fix.