Skip to content

screencast_start silently changes format and path for uppercase/unsupported file extensions #2206

@nebrass

Description

@nebrass

Summary

screencast_start validates the requested file extension with a case-sensitive endsWith() against ['.webm', '.mp4'] and silently falls back to .mp4 when nothing matches, instead of erroring. Combined with ensureExtension() (which replaces the existing extension), the recording can be written in a different format and to a different path than requested, with no warning.

(Reported originally by @ch-bas while testing; filing upstream with a reproduction and a fix.)

Affected code

  • src/tools/screencast.ts — the supportedExtensions loop uses filePath.endsWith(supportedExtension) (case-sensitive) with a silent .mp4 default.
  • src/utils/files.tsensureExtension() strips the existing extension via path.extname and appends the enforced one.

Present in v1.2.0 and on current main (the two files are unchanged between them).

Steps to reproduce

  1. Start the server with --experimentalScreencast=true (and --experimentalFfmpegPath <ffmpeg>).
  2. screencast_start with filePath: "demo.WEBM".
  3. screencast_stop.

Actual

Records MP4 to demo.mp4 — neither the requested format nor the requested path. The same happens for any unsupported extension, e.g. recording.avi silently becomes recording.mp4.

Reproduced with the exact endsWith loop + ensureExtension run through node:path:

requested resolved path format
demo.webm demo.webm webm ok
demo.WEBM demo.mp4 mp4 wrong
demo.Webm demo.mp4 mp4 wrong
recording.avi recording.mp4 mp4 wrong
clip.MP4 clip.mp4 mp4 silently renamed

Expected

  • .WEBM / .Webm etc. treated as WebM (case-insensitive match).
  • An explicitly requested but unsupported extension rejected with an explicit error listing the supported formats, rather than silently switching format and path.

Minor related issue

When screencast_start is called without a filePath, it creates a temp directory via mkdtemp(). If page.screencast() then throws (e.g. ffmpeg missing), that directory is never cleaned up, leaking an empty temp dir per failed attempt.

Fix

PR incoming that (1) matches the extension case-insensitively, (2) rejects unsupported explicit extensions with a clear error, and (3) removes the generated temp directory when recording fails to start. Includes regression tests using the existing screencast test harness.

Environment

chrome-devtools-mcp v1.2.0 / current main.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions