Skip to content

fix(cli): cloud render finds files whose names the page writes with a percent escape - #8960

Merged
miguel-heygen merged 3 commits into
mainfrom
fix/cloud-literal-percent-name
Nov 27, 2026
Merged

miguel-heygen merged 3 commits into
mainfrom
fix/cloud-literal-percent-name

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

hyperframes cloud render no longer calls a file missing when the page writes its name with a percent escape, such as My%20Video.mp4. The two cases fixed:

  1. A composition names assets/My%20Video.mp4 and the project root holds assets/My Video.mp4. This is the common one: a space in a file name, escaped in the page.
  2. The file's own name holds the escape (browser downloads on Windows often keep %20 in the saved name) and the page names it as written.

Why

The local preview finds both files, because it tries the decoded name and then the name as written. The cloud upload refused the project instead: The composition references "assets/My%20Video.mp4", which is not in the project folder. That happened although the file is there, so a video that plays locally could not be rendered in the cloud. A reference the film does not strictly need was left out of the upload without a word.

Related work

None.

How

Both changes are in packages/cli/src/utils/publishProject.ts:

  • includeReferencedProjectFile looked the project root up by the raw name only. It now tries every spelling decodeUrlPathVariants gives, decoded first, as the preview does.
  • tryResolveExternal stops at the first spelling for a file inside the project folder. It now orders the spellings so that one present on disk inside the project folder comes first. When both or neither are present, the order is unchanged (decoded first). Only paths inside the project folder are checked, so the CLI still never looks at another computer's share or a device path. publishProject.networkShare.win32.test.ts pins that, and it failed on a first version of this change that checked every spelling.

Grep for other places that resolve a reference by its raw name (resolve(<dir>, raw…) in packages/cli/src, tests excluded): none.

Test plan

  • Unit tests added: publishProject.missing.test.ts, "a file named with a percent escape", with 3 tests: the escaped space resolved from the root, a file whose own name holds the escape, and a refusal when neither spelling is on disk.
  • Fails without the fix: on origin/main both staging tests fail with The composition references "...%20Video.mp4", which is not in the project folder. Reverting only the root lookup fails only the first test, and reverting only the ordering fails only the second. With the fix the file passes 3 runs in a row (11/11).
  • Sibling suites: every src/utils/publishProject*, src/commands/cloud/*, urlPath and privateProjectFile test file passes (23 files, 315 tests).
  • Full packages/cli suite on a Linux box: 4 files fail (snapshot, snapshotHdrFrame, measure/diff-offset, measure/media, 14 frame-decoding tests), and the same 14 fail on unmodified origin/main on that box, so they come from its ffmpeg, not from this change.
  • Comments follow CONTRIBUTING.md "Comments".

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 · Use the same URL path for ranking and staging. In packages/cli/src/utils/publishProject.ts:759–775, relative references keep their query or fragment during the new existence check. Staging strips the suffix at line 594. With a literal percent-escaped filename in a nested composition and a query or fragment, neither spelling wins the ranking, so the decoded path can still report missing before the literal spelling is considered. Split the URL suffix before filesystem resolution and preserve it when rewriting. Cover a suffixed relative reference in the new staging tests.

P2 · Keep the new existence probe inside the filesystem boundary. The new existsSync runs before the existing network-root and link checks. Lexical containment does not establish that a path resolves within the project, and an existence probe can follow a symlink or junction. Choose among permitted candidates without following a link target during this preflight. The current direct-network-path test covers a different case.

This was source review at the pinned head. Required CI was still running.

— tai (automated review)

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 273 (base branch 271), smooth 49 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Newly passing (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Quarantined, measured but not gated (0)

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Both findings fixed at 93336ba8. The existence probe is gone.

Suffix (P2 1). tryResolveExternal now splits the query or fragment off every reference, relative ones included, before any spelling is resolved. It puts the suffix back on the rewritten reference. It tries every spelling of the name without the suffix, then every spelling of the whole value, because a file may really be named poster#art.svg. The existing publishProject.test.ts case pins that, and it failed on a version that only split. New test: "is staged when the reference also carries a query or a fragment" covers clips/My%20Video.mp4#t=1 (literal name, nested composition) and assets/My%20Logo.png?v=2 (decoded name at the root).

Probe ahead of the checks (P2 2). No spelling is checked for existence before the usual path anymore. Each spelling goes through archiveTargetOf in turn: its network-root check first, then includeReferencedProjectFile with its containment, staying-out, private-file and link checks, in their old order. A spelling not on disk returns false, and the next spelling is tried. "Not in the project folder" is thrown only after the last spelling. The root fallback now resolves from the spelling being tried instead of the raw value. includeCandidate and projectTargetOf are split out only to stay under the repo's complexity gate.

Proof. Each part was broken on its own:

  • Refusing on the first spelling fails 2 tests (literal name, suffix).
  • Resolving the root from the raw value fails 2 tests (root, suffix).
  • Keeping the suffix on relative names fails 1 test (suffix).

With the fix, publishProject.missing.test.ts passes 3 runs in a row (12/12). All 25 sibling files pass (329 tests): publishProject* including networkShare.win32, commands/cloud/*, urlPath, privateProjectFile, fileReferences, mountedCompositions and publishProxyBake. The full packages/cli suite on a Linux box fails the same 14 ffmpeg frame-decoding tests as unmodified origin/main on that box, and nothing else.

The description is frozen. This comment replaces its "How" section, and its test counts are now 4 new tests and 25 sibling files.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The previous suffix-lookup and existence-probe findings are resolved.

P2 · The nested literal filename still needs a URL the renderer can load. The new test only asserts the file is in the archive. The in-project relative branch in packages/cli/src/utils/publishProject.ts leaves the original URL in the page. Then packages/parsers/src/rewriteSubCompPaths.ts:85–91 probes only the decoded sibling when deciding whether to rebase a nested composition’s URL. I checked the pinned helper with the test’s literal-percent sibling: it returns clips/My%20Video.mp4#t=1 unchanged, so after inlining it still points at the root’s clips directory rather than the staged nested file. Either rewrite the selected filename to a correctly encoded URL before packaging or make the render-side rebase recognize the literal spelling. Add an assertion on the compiled URL or a render-facing test alongside the staging assertion.

The Comments job also failed because the comment share increased in publishProject.ts. CI log

— tai (automated review)

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Both fixed at 12641e9e.

Nested literal filename (P2). The fix is on the render side, in rewriteAssetPath (packages/parsers/src/rewriteSubCompPaths.ts). Before rebasing a plain relative path, it now probes the sibling under the decoded spelling, then under the spelling as written. That is the same order as resolveLocalAssetCandidates. The bundler, the producer compiler (inlineSubCompositions.ts:610), lint and the cloud offload (offload.ts:1098, whose probe is the archive map) all route through it. A sibling found as written is emitted encoded, so clips/My%20Video.mp4#t=1 in compositions/intro.html becomes compositions/clips/My%2520Video.mp4#t=1, which loads the staged literal file after inlining.

New test in rewriteSubCompPaths.test.ts, "finds a sibling whose own name holds the escape, as written". On the old rewriter it fails with Received: "clips/My%20Video.mp4#t=1", the case you reproduced. With the fix it passes 3 runs in a row. When no sibling exists under either spelling, the path stays as authored, as before.

Comments gate. publishProject.ts is back to one added comment line. The rest moved into names (includeCandidateOnDisk). scripts/comment-ratchet.mjs against the merge-base: 2 changed source files at or under their share.

Suites at this head: parsers all 64 files (1652 tests), core src/compiler 31 files, lint all 33 files, and the CLI publishProject*, commands/cloud, cloud, urlPath, privateProjectFile, fileReferences, mountedCompositions and publishProxyBake files (44 files, 541 tests). All pass.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The nested asset rebase now selects the literal-percent sibling when the decoded sibling is absent, encodes the literal percent, and preserves the media fragment. All 17 targeted parser tests passed, and the new regression failed with the previous source. The Comments job and all applicable required checks passed. I did not run a cloud render.

— tai (automated review)

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Render timing, main vs this branch at 12641e9e, on a Linux x64 box. Both CLI builds come from one tree with the same dependencies. The main build has the merge-base's publishProject.ts and rewriteSubCompPaths.ts, and it contains none of the branch's code. hyperframes render <fixture>, 3 rounds, interleaved with the order alternating each round, one render at a time. All 18 renders exited 0.

Fixture Main, median of 3 Branch, median of 3 Change
chat (sub-compositions) 5.25 s 5.19 s -1.1%
style-4-prod 9.01 s 9.05 s +0.4%
style-7-prod 9.55 s 9.66 s +1.2%

All three are within 3%. The box was shared with other work, which is why each round was interleaved.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 3c85fbc Nov 27, 2026
93 checks passed
@miguel-heygen
miguel-heygen deleted the fix/cloud-literal-percent-name branch November 27, 2026 04:54
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