Repository navigation
fix(web): fail setInputFiles on a missing path as INVALID_ARGUMENT before clicking - #2039
Conversation
There was a problem hiding this comment.
No issues found across 5 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Checked c2a3b18 against main 3e7d19d. The approach is sound. A precondition check in the engine, before the element lookup, is better than mapping Playwright's ENOENT by message, and it means a chooser button is never clicked. TestError('INVALID_ARGUMENT', ...) matches route.fulfill's requireFile in the same package and the agent's upload. Playwright parity holds: Playwright's client stats each file in convertInputFiles before it touches the element, so it fails just as early (with a raw ENOENT), and it accepts a directory too. A @e2e-dev/web patch changeset is correct, and no peer floor is needed.
Must fix
packages/web/tests/unit/actions.test.ts:238-288: five existing unit tests now fail, because they pass the made-up path/tmp/a.txtand the new stat rejects it before the mocked chooser or element runs (TestError: setInputFiles path does not exist: /tmp/a.txt). The tests are: "uploads through a file chooser it awaits before clicking a button", "sets a file input directly", "fails as NOT_ACTIONABLE when the click opens no file chooser", "sets no files when the operation is cancelled while the chooser is pending", "reports a failed click without leaving the chooser wait unhandled". Write a real file in amkdtempSyncdir in that file, likeupload-actions.test.tsdoes, and use its path. The PR only ran the integration file. Runvitest run tests/unittoo.- CI
check(spec.yml) fails atpnpm plugins:check:Plugin files are out of date; run pnpm plugins:sync: plugins/e2e/skills/e2e/references/writing-tests.md. Runpnpm plugins:syncand commit the result.
Should fix
packages/web/src/actions.ts:239:statSync(file, { throwIfNoEntry: false })still throws onEACCES(a directory on the path the runner may not search). That error escapes as a rawError, so it is stillENGINE_FAILURE, exit 3.requireFileinroute-options.ts:175already handles this with a try/catch. Use the same shape here, or share one helper between the two, so both file-path options fail the same way.
Nits
- Out of scope, only noting it: two directories, or a directory mixed with files, still fail with Playwright's plain
Error("Multiple directories are not supported", "File paths must be all files or a single directory"), so they areENGINE_FAILUREtoo. The same pre-check could cover them later.
Verified
vitest run tests/integration/upload-actions.test.ts: 16/16.vitest run tests/unit: 5 failed / 379 (above). These same tests pass on main.tsc --noEmitand oxlint clean.- Mutants, each caught by the 4 new cases: drop the check (4 fail), check only the first path (4 fail), throw
EngineErrorinstead ofTestError(4 fail). - CI:
test (*)matrix was still running when I checked. It should fail on the unit tests above.
|
thanks, pushed f345e00
Verified
|
There was a problem hiding this comment.
All reported issues were addressed across 9 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked f345e00 against main c30354f. Every earlier ask is done: the 5 actions.test.ts tests upload a real file from a mkdtempSync dir, pnpm plugins:check is clean, and statPath in support.ts now handles EACCES for both setInputFiles and route.fulfill. The new chmod 000 case covers it. No must-fix left.
Should fix
- The changeset,
docs/reference/screen.mdx:933, bothwriting-tests.mdcopies and the error message (actions.ts:240) say a path that "cannot be read" fails asINVALID_ARGUMENT. That is not what the check does. It only rejects a pathstatcannot reach. I made a mode 000 file (its directory is fine) and uploaded it through a chooser button on a local Chromium: no error, and the button was clicked. Cubic's P2 onwriting-tests.md:317is real. Reword it to what is checked, e.g. "a path that does not exist or sits under a directory the runner cannot search", in all five places. Or make the claim true withaccessSync(file, constants.R_OK)in thesetInputFilescheck, but that is stricter than Playwright, so rewording is the smaller change.
Nits
- Cubic's P3 (
actions.test.ts:18, the module-level temp dir is never removed) is real but minor.upload-actions.test.tsalready leaks its temp dir the same way. Fix it or leave it. - Overlap with #1883 (in-memory uploads): it changes
uploadFilesto takeParameters<ElementHandle['setInputFiles']>[0](paths or payloads) and adds asetInputFilePayloadsarm. Whichever PR lands second has to move this stat check out ofuploadFilesinto thecase 'setInputFiles'arm ofdispatchLocatorAction, so payloads are never stat'ed. It is a small textual conflict, not a design one.
Verified
vitest run tests/unit(web): 38/38 files, 384 tests pass. I had to clear a stale.viteoptional-peer cache first, which was a local env issue and not this PR.upload-actions+ route integration: 73/73 pass.tsc --noEmit, oxlint andpnpm plugins:checkare clean.- Mutants: dropping the try/catch in
statPathfails the newEACCEScase (2 fail,ENGINE_FAILURE). Checking only the first path fails 4. - The branch merges cleanly into main c30354f, so no rebase is needed.
mergeable_stateisblockedonly on review. - CI: spec, docs, docs translations, mobile and benchmark are
action_required, because fork workflows are not approved yet. Only the bot checks ran (cubic, label, pr-policy, pr-size, all green).
Superseded by the latest automated re-check.
|
[claude-opus-5-5] automated review on behalf of @okwasniewski The red |
…, and clean up the unit temp dir
|
merged main and pushed c78050a
Verified
will /ready once check is green |
There was a problem hiding this comment.
0 issues found across 7 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked c78050a against main c30354f. The new commits are a main merge plus the docs fix we asked for, and nothing else.
- Done: "cannot be read" is now "does not exist or sits under a directory the runner cannot search" in the changeset,
docs/reference/screen.mdx:948, bothwriting-tests.mdcopies, and theactions.tserror message and doc comment. That matches whatstatPathchecks. The test expectations use the new message, and no "cannot be read" or "unreadable" is left in the diff. - Done:
actions.test.tsnow removes its temp dir inafterAll(cubic's P3). - No other code changed.
uploadFiles,statPathand the route path are the same as at f345e00.
Must fix
- None.
Before the label
- Cubic's P2 thread on
plugins/e2e/skills/e2e/references/writing-tests.mdis still open. Reply that c78050a fixed it and resolve the thread. The/readygate needs every thread resolved. - Your
/readyreached GitHub asC:/Program Files/Git/ready. Git Bash rewrites an argument that starts with/into a Windows path. Post/readyfrom the GitHub web UI, or useMSYS_NO_PATHCONV=1, once CI is green.
Verified
- Diffed the PR against main at both heads: only the rewording and the
afterAllcleanup differ. - CI at c78050a: docs, docs translations and mobile pass.
check,testx5,webandbenchmarkwere still running at 22:15 UTC. Cubic found no issues in the new commits. mergeable_stateunstableis only the running checks, and there are no conflicts.
|
spec / check went red on fixed in ac044a5: Verified
|
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
|
/ready |
|
Fix these and comment |
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked ac044a5 against main 7e32054. The new commits are a main merge and the ENOENT text fix, nothing else.
- The fix is right.
statPathnow returns Node's stat error, and the setInputFiles message appends it:setInputFiles path does not exist or is under a directory the runner cannot search: ENOENT: no such file or directory, stat '<path>'. The ported testbed test only asks forENOENT: no such file or directoryplus the path, and both are there. It also matches Playwright 1.65.1, which runsfs.promises.staton each path inresolvePathsAndDirectoryForInputFilesand throws Node's error unchanged. - No regressions. "cannot be read" has not come back anywhere in the diff. The message shows the path the caller passed, as before, plus Node's errno text, and no secret goes into it.
route.fulfillbehaves and words its error the same as at c78050a. The changeset, docs and skill copies still describe the check correctly. - Every earlier thread is resolved.
Must fix
- None.
Label
- Labeled Ready for Human Review on our side, so no
/readyis needed this time.
Nits
packages/web/src/actions.ts: when a path runs through a regular file, Node saysENOTDIR, and "does not exist or is under a directory the runner cannot search" still covers that well enough. Fine to leave.
Verified
upload-actions.test.ts,routes.test.tsandactions.test.tspass at the head (128 tests).- Mutant: I put the old
${file}back in the message in place of Node's text, and 6upload-actionstests failed. Reverted. - CI at ac044a5 is all green, including
spec, which runs the testbedset-input-files.e2e.ts, pluscheck, thetestmatrix,web,benchmarkand docs. Cubic found 0 issues. mergeable_state isclean.
What and why
setInputFilesnow fails withINVALID_ARGUMENTwhen a path doesn't exist, a test error, exit 1. same idea as the agent'supload.ENOENTfell throughclassifyActionErrortoENGINE_FAILURE, so a typo'd fixture path made the run exit 3 like an infra failure.statSyncat the top ofuploadFiles, so it runs before the element lookup and before a chooser button is clicked. a directory still goes through to playwright as before.docs/reference/screen.mdxand the skill'swriting-tests.mdupdated.Issue
Fixes #2038
Verified
Ran it locally: yes. the
missing-uploadrepro (setInputFiles('fixtures/avatar.png')with no such file), published 0.16.1 vs a build of this branch:ENGINE_FAILURE: ENOENT: no such file or directory, stat '...\fixtures\avatar.png'INVALID_ARGUMENT: setInputFiles path does not exist: ...\fixtures\avatar.pngpnpm --filter @e2e-dev/web exec vitest run tests/integration/upload-actions.test.ts: 16/16. the 4 new cases (a file input and a chooser button, each through a locator and an element, with a missing file and a path under a file) fail on main and check that nothing got set or clicked.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.