Skip to content

feat: support uploading multiple files with upload_file - #2257

Merged
Lightning00Blade merged 8 commits into
ChromeDevTools:mainfrom
serhiizghama:feat/upload-file-multiple
Aug 11, 2026
Merged

Lightning00Blade merged 8 commits into
ChromeDevTools:mainfrom
serhiizghama:feat/upload-file-multiple

Conversation

@serhiizghama

Copy link
Copy Markdown
Contributor

Closes #1217. upload_file only took a single path, so there was no way to fill an input[type=file][multiple] in one call.

filePath now also accepts an array of paths. A plain string still works for the single-file case, so existing callers don't change — Puppeteer's uploadFile/fileChooser.accept already take multiple paths, so the handler just normalizes to an array and forwards them.

The union (string | string[]) needed a bit of plumbing: the CLI generator threw on non-scalar types, the docs generator rendered it as unknown, and the telemetry transformer didn't know ZodUnion. The CLI exposes the single-value form (it can't pass arrays anyway), the docs show string or array, and metrics count it like an array with scalars normalized to one. Regenerated artifacts are included.

Added a test that uploads two files to a multi-file input and asserts both land, plus telemetry coverage for the union. npm run typecheck, lint/prettier, and the upload + transformation tests all pass.

Allow filePath to be an array so a single call can populate inputs with
the multiple attribute. A string is still accepted for the common
single-file case, so existing callers are unaffected.
The CLI/docs generators and the telemetry transformer only handled
scalar and array params, so the upload_file union tripped them. Map the
union to its string form for the CLI, render both members in the docs,
and count it as an array in metrics (scalars normalized to one). Includes
the regenerated artifacts.
@itxaiohanglover

Copy link
Copy Markdown
Contributor

Good feature addition! Supporting array filePath for multiple file uploads is useful. The CLI schema update to handle string | string[] union types is a nice touch — exposing the single-value form for CLI is pragmatic.

Comment thread src/tools/input.ts Resolved
Replace the string | string[] union with a single filePaths: string[]
param. A plain array is easier for models to target than a union, and it
drops the union handling that was needed in the CLI and docs generators
and in the telemetry transform.
@serhiizghama

Copy link
Copy Markdown
Contributor Author

Done — switched to a plain filePaths: zod.array(zod.string()).min(1) and updated the description. Dropping the union also let me revert the union handling I'd added to the CLI/docs generators and the telemetry transform, so the diff is smaller now. Single path still works, just as [path].

Comment thread src/tools/input.ts Resolved
@serhiizghama

Copy link
Copy Markdown
Contributor Author

Good call — shortened it, went with your suggestion exactly.

Comment thread src/tools/input.ts Resolved
@Lightning00Blade
Lightning00Blade requested a review from OrKoN August 11, 2026 09:56
@Lightning00Blade
Lightning00Blade added this pull request to the merge queue Aug 11, 2026
Merged via the queue into ChromeDevTools:main with commit c8a2393 Aug 11, 2026
19 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.

Support multi-file uploads for existing-session mode

3 participants