Skip to content

remotion: Truncate long blob URLs in delayRender labels - #9813

Merged
JonnyBurger merged 3 commits into
remotion-dev:mainfrom
amir-rezaei:fix/truncate-src-blob-and-non-string-guard
Jul 29, 2026
Merged

remotion: Truncate long blob URLs in delayRender labels#9813
JonnyBurger merged 3 commits into
remotion-dev:mainfrom
amir-rezaei:fix/truncate-src-blob-and-non-string-guard

Conversation

@amir-rezaei

Copy link
Copy Markdown
Contributor

Description

This PR updates truncateSrcForLabel in packages/core/src/truncate-src-for-label.ts.

Details

  • Adds support for truncating long blob: URLs alongside data: URLs to keep delayRender labels compact.
  • Adds a non-string type guard to prevent runtime errors if non-string values are passed.

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment Jul 29, 2026 7:34am
remotion Ready Ready Preview, Comment Jul 29, 2026 7:34am

Request Review

@pullfrog pullfrog Bot 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.

Reviewed changes — adds blob URL truncation and a non-string runtime guard to truncateSrcForLabel, used in delayRender labels for <Img> and <CanvasImage>.

  • Handle blob: URLs — extends the existing data: URL truncation to also cover blob: URLs, keeping delayRender labels compact.
  • Non-string type guard — adds a typeof check so the function doesn't throw at runtime if a non-string value reaches it.

ℹ️ Tests should cover the new behavior

The test file at packages/core/src/test/truncate-src-for-label.test.ts doesn't cover blob URL truncation or the non-string type guard. Worth adding — the existing tests on data URLs are a good template to follow.

Technical details
# Missing test coverage for blob URLs and non-string guard

## Affected sites
- `packages/core/src/test/truncate-src-for-label.test.ts` — no test for blob URL truncation or non-string guard.

## Required outcome
- Add a test: a long `blob:` URL should be truncated (mirroring the existing data URL test on line 21-28).
- Add a test: passing `null` or `undefined` returns a safe fallback string rather than throwing.

## Open questions for the human
- What's the right expected return value for non-string input? The current implementation returns `String(src ?? '')` which produces `""` for `null`/`undefined` but `"[object Object]"` for objects. Decide the desired contract before writing tests.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Claude Opus not used — the program covers this model; add its provider key to run your pick) | 𝕏

// unreadable and bloats log output
export function truncateSrcForLabel(src: string): string {
if (src.startsWith('data:') && src.length > 100) {
if (typeof src !== '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.

The type signature (src: string) contradicts the runtime typeof guard. If non-string values can reach this function in practice, update the parameter type to unknown. Otherwise the guard is dead code at compile time and callers writing truncateSrcForLabel(foo as string) will never be caught by the type system.

Technical details
# Type guard contradicts declared parameter type

## Affected sites
- `packages/core/src/truncate-src-for-label.ts:3``src: string` vs `typeof src !== 'string'` guard at line 4
- `packages/core/src/Img.tsx:145,200,211` — callers use `as string` assertions
- `packages/core/src/canvas-image/CanvasImage.tsx:230,305,344,388``actualSrc` from `usePreload` flows in unasserted

## Required outcome
- If non-string values can reach this function at runtime: change the signature to `src: unknown` and remove the `as string` assertions at call sites.
- If they cannot: drop the `typeof` guard and fix any callers that pass potentially-non-string values at the source.

export function truncateSrcForLabel(src: string): string {
if (src.startsWith('data:') && src.length > 100) {
if (typeof src !== 'string') {
return String(src ?? '');

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 fallback String(src ?? '') silently converts any non-string to a string representation, which could mask real bugs. If a caller passes an object (e.g. a ref that hasn't mounted), the label becomes "[object Object]" — no more useful than a crash, and harder to notice. Consider returning a fixed descriptive label like "[unexpected source]" or widening the type and letting TypeScript catch the problem at compile time instead.

@JonnyBurger JonnyBurger changed the title fix(core): handle blob URLs and add non-string type guard in truncateSrcForLabel remotion: Truncate long blob URLs in delayRender labels Jul 29, 2026
@JonnyBurger
JonnyBurger merged commit 5aa0ca5 into remotion-dev:main Jul 29, 2026
41 of 43 checks passed
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.

3 participants