Skip to content

fix: respect caller format and allow opting out of f_auto - #1097

Merged
tsi merged 2 commits into
masterfrom
fix/VIDEO-21243-format-opt-out
Oct 20, 2026
Merged

tsi merged 2 commits into
masterfrom
fix/VIDEO-21243-format-opt-out

Conversation

@tsi

@tsi tsi commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Jira: VIDEO-21243

Why

The player adds f_auto:video to every auto source, and integrators had no way to opt out. A caller's own fetch_format was chained in front of the default (f_mp4/f_auto:video/...) rather than replacing it, and format inside a transformation was silently dropped.

What changed

  • A caller-supplied fetch_format replaces the default f_auto:video, and the source MIME type follows it.
  • format inside a transformation is an alias of fetch_format. If both are set, fetch_format wins.
  • sourceTypes: [''] delivers the asset as-is, with no f_auto:video and no extension. A bare URL resolves and serves the original file.
  • Added getTransformationValue to src/utils/cloudinary.js. isKeyInTransformation now uses it and behaves the same.
Config Before After
default f_auto:video/sea_turtle unchanged
transformation: { fetch_format: 'mp4' } f_mp4/f_auto:video/sea_turtle, video/auto f_mp4/sea_turtle, video/mp4
transformation: { format: 'mp4' } f_auto:video/sea_turtle, video/auto f_mp4/sea_turtle, video/mp4
transformation: { fetch_format: 'auto' } f_auto/f_auto:video/sea_turtle unchanged
sourceTypes: [''] sea_turtle. (broken), video/ sea_turtle, video/auto

The default output is byte-identical. Explicit sourceTypes (mp4, hls, ...) are unaffected.

Not in this PR

  • raw_transformation: 'f_mp4' still gets f_auto:video added.
  • The broader rule-based refactor of the four defaults described in the ticket.
  • Docs for the new behaviour.

Testing

  • New unit tests in test/unit/videoSource.test.js cover caller fetch_format/format and sourceTypes: [''].
  • npm run test:unit passes (141 tests).

A caller-supplied fetch_format (or its format alias) now replaces the
default f_auto:video, with a matching MIME type. An empty source type
delivers the asset as-is, without f_auto:video or an extension.

VIDEO-21243
@tsi
tsi requested a review from a team as a code owner October 14, 2026 08:43
@netlify

netlify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cld-vp-esm-pages ready!

Name Link
🔨 Latest commit 4f864c6
🔍 Latest deploy log https://app.netlify.com/projects/cld-vp-esm-pages/deploys/6ad6ebc3c90776e8c97f500d
😎 Deploy Preview https://deploy-preview-1097--cld-vp-esm-pages.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cld-video-player ready!

Name Link
🔨 Latest commit 4f864c6
🔍 Latest deploy log https://app.netlify.com/projects/cld-video-player/deploys/6ad6ebc319b88381e223ca53
😎 Deploy Preview https://deploy-preview-1097--cld-video-player.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

if (callerFormat && callerFormat !== 'auto') {
// Respect the caller's format instead of adding f_auto:video
if (!fetchFormat) {
opts.transformation = mergeTransformations(opts.transformation, { fetch_format: callerFormat });

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.

fetch_format: 'auto:video' or any auto:* passes the !== 'auto' check. The code then treats it as a concrete format. formatToMimeTypeAndTransformation('auto:video') returns an unknown MIME type, so the source gets a wrong type and Video.js may drop it. Before the PR this gave f_auto:video with type video/auto. Fix: use startsWith('auto').

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. Any value that starts with auto now uses the default path, and the output is the same as on master. I added a test.

if (!fetchFormat) {
opts.transformation = mergeTransformations(opts.transformation, { fetch_format: callerFormat });
}
[type] = formatToMimeTypeAndTransformation(callerFormat);

@adimiz1 adimiz1 Oct 20, 2026 •

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 comment says format is an alias of fetch_format, but in url-gen format is a URL key (the file extension, URL_KEYS in backwards/transformation.js), while fetch_format is what emits f_.
Before this PR, transformation: { format: 'mp4' } meant ".mp4 extension". Now it also adds f_mp4. Is that change intended?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The URL builder ignores format in a transformation component. Object, instance and chained forms all give one f_mp4 and no extension. See the alias tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, intended. In this player, format in transformation did not set the extension before this PR. On master, { format: 'mp4' } gives f_auto:video/sea_turtle, so the key was ignored. Treating it as an alias of fetch_format gives it a meaning without changing existing output. Callers who want the extension can use sourceTypes: ['mp4'].

@adimiz1
adimiz1 self-requested a review October 20, 2026 04:23
@tsi
tsi merged commit 18f7ca4 into master Oct 20, 2026
10 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.

2 participants