Skip to content

@remotion/studio-server: Hint when someone forgets to wrap in staticFile()#7002

Merged
JonnyBurger merged 3 commits intomainfrom
cursor/trivial-issue-resolution-9649
Apr 6, 2026
Merged

@remotion/studio-server: Hint when someone forgets to wrap in staticFile()#7002
JonnyBurger merged 3 commits intomainfrom
cursor/trivial-issue-resolution-9649

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Apr 6, 2026

Summary

  • Fixes Dev server: log hint to use staticFile() when a 404’d URL matches a public/ file #7001
  • Added a fallback hint in Studio server routes: when a root URL request (for example /video.mp4) falls through, and public/video.mp4 exists, the server logs a warning suggesting staticFile("video.mp4").
  • Added guardrails so hints are only emitted for likely asset requests (GET/HEAD, path has file extension, file exists in public/, and is not a directory).
  • Added deduplication to avoid repeated noisy warnings for the same file path during a dev session.

Implementation details

  • New helper: packages/studio-server/src/preview-server/get-static-file-fallback-hint.ts
  • Integrated hint logging into fallback handling in packages/studio-server/src/routes.ts
  • New tests: packages/studio-server/src/test/get-static-file-fallback-hint.test.ts

Validation

  • bun run formatting (package: @remotion/studio-server) ✅
  • bun run lint (package: @remotion/studio-server) ✅
  • bun test src (package: @remotion/studio-server) ✅

Notes / tradeoffs

  • Monorepo-wide bun run build and bun run stylecheck are currently failing in this environment due known unrelated constraints (@remotion/lambda-go requires Go >= 1.23; runner has 1.22.2) and an existing unrelated @remotion/promo-pages build failure.
  • The hint is intentionally conservative to avoid logging on SPA/document navigation paths without file extensions.
Open in Web View Automation 

Co-authored-by: Jonny Burger <hi@jonny.io>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment Apr 6, 2026 8:31am
remotion Ready Ready Preview, Comment Apr 6, 2026 8:31am

Request Review

Clarify the 404 hint copy, log at error level, only emit when the path
contains a dot, and point users to the assets docs.

Made-with: Cursor
@JonnyBurger JonnyBurger marked this pull request as ready for review April 6, 2026 08:21
@JonnyBurger JonnyBurger enabled auto-merge April 6, 2026 08:21
@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog bot commented Apr 6, 2026

Reviewed PR #7002. Submitted feedback with 4 inline comments: use Log.warn instead of Log.error for the hint, remove redundant pathname.includes('.') guard, fix the staticFile() argument to use the stripped relative path, and a note about the unbounded module-scope Set.

Task list (6/6 completed)
  • Read and understand the full diff
  • Read existing routes.ts for context around the integration point
  • Verify the getStaticFileFallbackHint logic for correctness
  • Check for issues in routes.ts integration
  • Verify test coverage and correctness
  • Submit review

Pullfrog  | View workflow run | Triggered by Pullfrog | Using Big Pickle (free) | 𝕏

@JonnyBurger JonnyBurger changed the title @remotion/studio-server: Add staticFile hint when root URL matches public asset @remotion/studio-server: Hint when someone forgets to wrap in staticFile() Apr 6, 2026
Copy link
Copy Markdown
Contributor

@pullfrog pullfrog bot left a comment

Choose a reason for hiding this comment

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

Important

Several issues to address: wrong log level, redundant guard, incorrect staticFile() argument format, and a module-level Set that leaks state across the process lifetime.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Big Pickle (free) | 𝕏

!loggedStaticFileHints.has(staticFileHint)
) {
loggedStaticFileHints.add(staticFileHint);
RenderInternals.Log.error(
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.

This is a hint/suggestion, not an error. The existing convention in this package is to use Log.warn for advisory messages (see get-package-manager.ts, log-update.ts). Log.error should be reserved for actual failures.

Suggested change
RenderInternals.Log.error(
RenderInternals.Log.warn(

Comment on lines +115 to +118
if (
staticFileHint &&
pathname.includes('.') &&
!loggedStaticFileHints.has(staticFileHint)
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 pathname.includes('.') check is fully redundant — getStaticFileFallbackHint already returns null when path.extname(normalizedPathname) is falsy, which covers the same case. Remove it to avoid duplicating the guard logic.

Suggested change
if (
staticFileHint &&
pathname.includes('.') &&
!loggedStaticFileHints.has(staticFileHint)
if (
staticFileHint &&
!loggedStaticFileHints.has(staticFileHint)
) {

[
`"${pathname}" was requested but not found.`,
'To import assets from the public/ folder, you must wrap them in staticFile(): https://www.remotion.dev/docs/assets',
`Change \`"${pathname}"\` to \`staticFile("${pathname}")\` to fix the error.`,
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.

pathname here is e.g. /video.mp4 (with a leading slash). The suggested fix tells the user to write staticFile("/video.mp4"). While staticFile tolerates a leading slash, the canonical docs style is staticFile("video.mp4") without one. Use staticFileHint (which is already the stripped relative path) instead of pathname:

`Change \`"${pathname}"\` to \`staticFile("${staticFileHint}")\` to fix the error.`

import type {RemotionConfigResponse} from './remotion-config-response';

const editorGuess = guessEditor();
const loggedStaticFileHints = new Set<string>();
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.

This Set lives at module scope, so it grows unboundedly for the lifetime of the dev server process. For a dev-session hint this is fine in practice (the set of distinct public assets is small), but worth noting — if you want to be defensive, you could cap it (e.g. stop logging after 50 entries) or clear it on HMR/config reloads. Not a blocker, just a consideration.

@JonnyBurger JonnyBurger merged commit dd2bb70 into main Apr 6, 2026
18 checks passed
@JonnyBurger JonnyBurger deleted the cursor/trivial-issue-resolution-9649 branch April 6, 2026 08:38
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.

Dev server: log hint to use staticFile() when a 404’d URL matches a public/ file

2 participants