Repository navigation
fix(cli): uploads leave out outside scripts; .ts counts as video only when it is one - #7818
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 65dc0bc
Publish, cloud render and feedback converge on the changed staging helper. Direct outside .js/.mjs references now receive the file_type warning; CSS remains allowed, and the local-render predicate still permits JavaScript. The budget-only follow-up changes no runtime code.
Important — the new sniff can block the local render server (packages/studio-server/src/helpers/outsideFile.ts:42–47). openSync(path, "r") can wait indefinitely on a nonregular file. The producer server calls this predicate through refusesOutsideLink before its existing openRegularFile check. In a real-server probe, the normal page returns 200, but requesting an outside nonregular .ts through a project link stalls instead of returning 404. With the base helper, the same request returns 404. This introduces a blocking read ahead of a guard that already refused the input safely.
Fix: open nonblocking, verify fstat(fd).isFile() before reading, and close the descriptor on every refusal. Reuse the descriptor-validation pattern already in packages/producer/src/services/fileServer.ts:763–790; do not rely on an earlier pathname stat. A temporary repair using that pattern restores 404 in the same server probe. Add this regression alongside regular TS/MTS controls.
Pre-existing security limits to keep explicit: the new two-sync-position sniff does not establish that a file is MPEG transport-stream data. Two staging probes use syntactically valid JavaScript accepted by the JS parser and still copy it as .ts/.mts. Also, an in-project symlink to outside JavaScript still enters the initial project-file staging branch without the new upload predicate (publishProject.ts:765–823); the direct outside-reference branch is narrower. Both kinds of content were already uploadable on the base, so these are not additional regression blockers. For the intended stronger guarantee, reject the demonstrated non-media false positives with appropriate bounded transport-stream validation, and apply outside-type checks to real-path-outside project links as well. An inside hardlink is treated as an own project file; it does not preserve an external pathname to classify.
User impact: projects depending on shared JavaScript outside the folder lose that script in cloud render, publish and feedback uploads. The warning names it and says to move it into the project, which is actionable. For regular-file inputs, local JavaScript and shared CSS retain their behavior. This is a deliberate compatibility change to account for when shipping.
Validation: frozen install/full build passed on the preceding source-identical head; the only subsequent change is the size budget. 141 CLI tests and 4 helper tests pass. The new script/TypeScript staging test fails when the upload type guard is disabled. Three additional policy-gap probes reproduce (two non-media TS/MTS cases and the project-link upload case), one direct-link/hardlink positive control, and a passing fixture generated by real ffmpeg as MPEG-TS. The real-server nonregular-file probe times out at this head and returns 404 with both the base helper and the temporary nonblocking repair. pnpm pack measures 171,223 bytes packed and 660,577 unpacked, within 172,000/662,000. Temporary changes restored. No live dev, cloud upload or native Windows walkthrough performed.
Need: yes · Size: ok · Reuse: shared outside-file policy and existing nonblocking descriptor checks · Simpler: distinct upload/local sets fit the intended behavior · Structure: fine (checked all three upload callers, staging branches and producer local-file consumers; no new policy framework)
Risk: high — handles local files across an upload boundary and introduces a blocking read on the render server.
Verdict: REQUEST CHANGES
Reasoning: The direct upload restriction works, but the new transport-stream sniff must preserve the server’s existing safe refusal of nonregular files.
— Rames
…needs binary bytes
|
Thanks. Commit 3eabfac addresses the review.
🤖 Addressed by Claude Code |
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 3eabfac81fae5534d37c6a3f59c1c9ab72d864ca.
The blocking-read finding is fixed: outsideFile.ts:49–66 opens nonblocking, verifies the opened descriptor is a regular file before reading, bounds the read, and closes it in finally. The original real-server probe now returns 404, with the normal page still returning 200. Removing O_NONBLOCK reproduces the timeout; restoring it restores 404.
The earlier text-only TS/MTS false-positive examples are now refused. Real ffmpeg-generated MPEG-TS and M2TS fixtures still reach upload staging. Direct outside .js/.mjs references remain excluded, local JavaScript/CSS behavior is retained, and the upload warning remains actionable.
Pre-existing follow-ups remain explicit: packet sync plus a binary byte is a heuristic, not proof that content cannot also be source code; comments may contain control bytes. In-project symlinks to outside scripts still stage as project files, as documented in the author's reply. These were already possible on the base and are not new regression blockers. Scope the guarantee to the direct outside-reference upload path.
Validation: frozen install and full build passed. bun run --cwd packages/cli test on the five previously reviewed staging/refusal suites plus temporary controls: 141 committed tests and five controls pass; the separate pre-existing project-link policy-gap control still fails its stronger exclusion expectation. bun run --cwd packages/studio-server test for outsideFile and mediaExtensions: 18 pass. Removing the new binary-byte guard makes the new text regression fail. Real-server FIFO probe: head 404, blocking-open mutation timeout, restored 404. Package measured 171,317 bytes packed / 661,012 unpacked, within 172,000/662,000. Temporary source changes restored; runs used the shared test gate. No live dev, cloud upload or native Windows walkthrough.
User impact remains deliberate: shared scripts referenced from outside the folder are omitted from publish/cloud/feedback uploads with a warning to move them into the project; local renders keep regular outside scripts.
Need: yes · Size: ok · Reuse: existing nonblocking descriptor-validation pattern · Simpler: already minimal · Structure: fine (checked shared predicate, upload staging and producer consumers; no split)
Risk: medium — upload compatibility change; the introduced local-server hang is repaired.
Verdict: APPROVE
Reasoning: The remaining introduced blocker is fixed and the original server reproduction now refuses safely; the existing coverage limits remain documented follow-ups.
— Rames
# Conflicts: # scripts/package-size-budgets.json
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at ba0514314d2e5f8229201c764660aad7e9b8a334.
Re-reviewed the merge of main c4d60c34 into the approved 3eabfac8. The remerge diff shows exactly one manual resolution: studio-server's unpacked budget keeps main's 672,000; its packed budget stays 172,000. Six of the original nine patch files are byte-identical. The changed code file, publishProject.ts, also picks up main's shared CSS URL scanner; its resolver callback still reaches the upload-specific outside-type predicate. The other changed original files are main's CLI documentation and package budgets.
The nonblocking regular-file sniff, binary-byte check and separate upload/local type sets are unchanged. Publish/cloud-render/feedback still use upload staging, while local renders keep their regular outside JavaScript allowance. The earlier heuristic-sniff and in-project-link coverage limits remain explicit follow-ups; this merge does not broaden the guarantee to those paths.
Validation at this head: frozen install/full bun run build passed. Through the shared test gate, CLI staging/refusal/CSS/feedback suites: 152 passed; Studio outside-file/media helpers: 18 passed. The original real-server nonregular-input probe returns 404, with the normal page still returning 200. pnpm pack measures 172,341 bytes packed / 665,538 unpacked. The packed size is 341 bytes above its nominal 172,000 budget, within the existing 1% tolerance; the repository’s actual listPackageSizeIssues returns no issues for those measurements and the 672,000 unpacked budget. No new live dev, cloud upload or native Windows walkthrough was performed. Independent code review found no new merge interaction blocker.
Need: yes · Size: merge delta · Reuse: main's shared CSS scanner and existing outside-file policy · Simpler: retain both through the existing callback · Structure: fine (checked staging callback, media predicate and merge resolution; no split)
Risk: medium — upload compatibility and local file handling, with prior safeguards retained.
Verdict: APPROVE
Reasoning: The merge preserves the reviewed outside-file restrictions and incorporates the shared CSS scan without bypassing the upload predicate.
— Rames
What
Publish, cloud render and feedback no longer copy scripts from outside the project folder. A
.tsor.mtsfile outside the project now counts as video only when its bytes are an MPEG transport stream, so TypeScript source is never copied as video. That check applies to uploads and to local renders.Why
An upload copies an outside file into
_ext/whenever a composition names it by a../or absolute path. Until now the upload list included.jsand.mjs, and.tspassed as video through itsvideo/mp2tmapping. So a composition could pull source files from folders next to the project into an upload. A composition only needs media, fonts and stylesheets from outside its folder.Related work
Narrows the outside-file type list added in #7636 and shared with local renders in #7647.
How
isUploadedOutsideFileTypeuses the local render list without thetext/javascripttypes from the preview server's MIME map (.js,.mjs, and any later script extension). Publish, cloud render and feedback all stage throughstagePublishFiles, which now calls it. An outside script is left out with the usualfile_typewarning andleft_outentry. For uploads, that warning now says "is not an image, video, audio, font or CSS file"..tsand.mtsmust be video. Both extensions name MPEG transport stream video as well as TypeScript source. Such a file counts as video only when every packet start in its first 768 bytes holds the0x47sync byte (188-byte packets from offset 0, or 192-byte M2TS packets from offset 4), and those bytes include at least one binary control byte. Real transport streams always have such bytes in their packet headers; source text does not. The file is opened non-blocking and checked withfstatbefore any read, so a named pipe is refused at once instead of stalling the local render server. This is a check against ordinary source files, not a full transport stream parser. A browser never runs a.tsfile served asvideo/mp2t, so no working composition loses anything..jsfiles, so a person's own render that uses a shared script folder keeps working. Its warning wording is unchanged.../shared/brand.cssloaded by<link>or@import, is a real pattern for people's own projects, and the existing tests cover it. CSS cannot run code.Size budget.
@hyperframes/studio-server's unpacked budget goes from 654,000 to 662,000 bytes. The upload rule and the transport stream check add about 2 KB of built code, and the package was already close to its limit.Not changed here: a symlink inside the project that leads to an outside file is still staged as a project file, as before #7636. Applying the type rule there would also leave out data files, such as a Lottie
.json, from folders people link into their own projects on purpose, so it needs its own decision.Trade-off: a project that loads a script from outside its folder, such as
<script src="../shared/lib.js">, now publishes or cloud-renders without that script, and the CLI warns about it. The fix is to move the script into the project folder. Files inside the project upload 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
publishProject.fileType.test.ts: outside.js,.mjs,.tsand.mtssource files are left out of the upload with thefile_typewarning; outside.tsand.mtstransport streams are still copied; the upload list holds media, fonts and CSS but not.jsor.mjs.New
studio-server/src/helpers/outsideFile.test.ts: scripts pass for a local render but not for an upload; stylesheets, fonts and media pass for both;.tsand.mtspass only as transport streams; text with a sync byte at every packet start is refused; a named pipe is refused without waiting (this test hangs with a blocking open); thefile_typewarning names the right types for an upload and a render. Making the.tscheck always pass fails this file.The publish, feedback, left-out and proxy-bake CLI test files pass (279 tests), as does
producer/src/services/outsideProjectAssets.test.ts. One existing test, about two file names that differ only by Unicode form, fails on macOS because APFS treats both names as one file; it does not involve outside files.tsc --noEmitfor cli, studio-server and producer, oxlint, oxfmt and the comment ratchet pass.