feat: support uploading multiple files with upload_file#2257
Open
serhiizghama wants to merge 3 commits into
Open
feat: support uploading multiple files with upload_file#2257serhiizghama wants to merge 3 commits into
serhiizghama wants to merge 3 commits into
Conversation
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.
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1217.
upload_fileonly took a single path, so there was no way to fill aninput[type=file][multiple]in one call.filePathnow also accepts an array of paths. A plain string still works for the single-file case, so existing callers don't change — Puppeteer'suploadFile/fileChooser.acceptalready 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 asunknown, and the telemetry transformer didn't knowZodUnion. The CLI exposes the single-value form (it can't pass arrays anyway), the docs showstring 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.