Skip to content

fix(web): fail setInputFiles on a missing path as INVALID_ARGUMENT before clicking - #2039

Merged
okwasniewski merged 6 commits into
e2e-inc:mainfrom
kunalgoesbyken:fix/web-set-input-files-missing-path
Nov 22, 2026
Merged

okwasniewski merged 6 commits into
e2e-inc:mainfrom
kunalgoesbyken:fix/web-set-input-files-missing-path

Conversation

@kunalgoesbyken

@kunalgoesbyken kunalgoesbyken commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What and why

  • setInputFiles now fails with INVALID_ARGUMENT when a path doesn't exist, a test error, exit 1. same idea as the agent's upload.
  • before, playwright's ENOENT fell through classifyActionError to ENGINE_FAILURE, so a typo'd fixture path made the run exit 3 like an infra failure.
  • the check is a statSync at the top of uploadFiles, so it runs before the element lookup and before a chooser button is clicked. a directory still goes through to playwright as before.
  • Throws row in docs/reference/screen.mdx and the skill's writing-tests.md updated.

Issue

Fixes #2038

Verified

Ran it locally: yes. the missing-upload repro (setInputFiles('fixtures/avatar.png') with no such file), published 0.16.1 vs a build of this branch:

main this branch
error ENGINE_FAILURE: ENOENT: no such file or directory, stat '...\fixtures\avatar.png' INVALID_ARGUMENT: setInputFiles path does not exist: ...\fixtures\avatar.png
exit code 3 1

pnpm --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

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

View guided diff

@github-actions github-actions Bot added the size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Nov 21, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

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 okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[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.txt and 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 a mkdtempSync dir in that file, like upload-actions.test.ts does, and use its path. The PR only ran the integration file. Run vitest run tests/unit too.
  • CI check (spec.yml) fails at pnpm plugins:check: Plugin files are out of date; run pnpm plugins:sync: plugins/e2e/skills/e2e/references/writing-tests.md. Run pnpm plugins:sync and commit the result.

Should fix

  • packages/web/src/actions.ts:239: statSync(file, { throwIfNoEntry: false }) still throws on EACCES (a directory on the path the runner may not search). That error escapes as a raw Error, so it is still ENGINE_FAILURE, exit 3. requireFile in route-options.ts:175 already 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 are ENGINE_FAILURE too. 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 --noEmit and oxlint clean.
  • Mutants, each caught by the 4 new cases: drop the check (4 fail), check only the first path (4 fail), throw EngineError instead of TestError (4 fail).
  • CI: test (*) matrix was still running when I checked. It should fail on the unit tests above.

@github-actions github-actions Bot added size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile and removed size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile labels Nov 21, 2026
@kunalgoesbyken

Copy link
Copy Markdown
Contributor Author

thanks, pushed f345e00

  • the 5 unit tests in actions.test.ts now upload a real file from a mkdtempSync dir, same as upload-actions.test.ts
  • added statPath in support.ts (stat with throwIfNoEntry false plus try/catch), and both uploadFiles and requireFile go through it now, so EACCES is INVALID_ARGUMENT on both paths. the message says "does not exist or cannot be read" since it covers both cases, and docs/skill/changeset say the same
  • new integration case: a file under a chmod 000 dir fails as INVALID_ARGUMENT with no click. it skips on windows and root since perms don't apply there
  • ran plugins:sync

Verified

  • vitest run tests/unit: actions + route tests pass. the only failures are 5 in install.test.ts, which fail on main on windows too (ERR_UNSUPPORTED_ESM_URL_SCHEME, a windows path issue)
  • upload-actions + route integration: 71 passed, 2 skipped (the eacces case on windows, so CI on linux is what runs it)
  • tsc --noEmit, oxlint and plugins:check are clean

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

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

Comment thread packages/web/tests/unit/actions.test.ts Resolved

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[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, both writing-tests.md copies and the error message (actions.ts:240) say a path that "cannot be read" fails as INVALID_ARGUMENT. That is not what the check does. It only rejects a path stat cannot 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 on writing-tests.md:317 is 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 with accessSync(file, constants.R_OK) in the setInputFiles check, 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.ts already leaks its temp dir the same way. Fix it or leave it.
  • Overlap with #1883 (in-memory uploads): it changes uploadFiles to take Parameters<ElementHandle['setInputFiles']>[0] (paths or payloads) and adds a setInputFilePayloads arm. Whichever PR lands second has to move this stat check out of uploadFiles into the case 'setInputFiles' arm of dispatchLocatorAction, 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 .vite optional-peer cache first, which was a local env issue and not this PR. upload-actions + route integration: 73/73 pass. tsc --noEmit, oxlint and pnpm plugins:check are clean.
  • Mutants: dropping the try/catch in statPath fails the new EACCES case (2 fail, ENGINE_FAILURE). Checking only the first path fails 4.
  • The branch merges cleanly into main c30354f, so no rebase is needed. mergeable_state is blocked only 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).

@okwasniewski
okwasniewski dismissed their stale review November 21, 2026 16:21

Superseded by the latest automated re-check.

@okwasniewski

Copy link
Copy Markdown
Member

[claude-opus-5-5] automated review on behalf of @okwasniewski

The red check is not from this PR: CI ran on a stale merge ref based on main a2d0363, where apps/desktop-testbed could not resolve ai (fixed on main by #2044). Please merge current main to retrigger CI; once it is green, comment /ready and the label goes on (code is ready from our side, see the review above).

@kunalgoesbyken

Copy link
Copy Markdown
Contributor Author

merged main and pushed c78050a

  • reworded the claim in all five spots (changeset, screen.mdx, both writing-tests.md copies, the error message + doc comment in actions.ts) to "does not exist or sits under a directory the runner cannot search", so it says what the stat check actually does. went with the rewording, not accessSync, to stay as lenient as playwright
  • the unit temp dir now gets removed in afterAll, checked that a run leaves no e2e-actions-* folder behind
  • noted the feat: support in-memory file uploads #1883 overlap, whichever lands second moves the stat check into the setInputFiles arm

Verified

  • web unit: 387 passed, only the 5 windows-only install.test.ts failures that also fail on main
  • upload-actions + route integration: 87 passed, 2 skipped (the chmod cases on windows)
  • tsc --noEmit, oxlint, plugins:check clean

will /ready once check is green

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

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 okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[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, both writing-tests.md copies, and the actions.ts error message and doc comment. That matches what statPath checks. The test expectations use the new message, and no "cannot be read" or "unreadable" is left in the diff.
  • Done: actions.test.ts now removes its temp dir in afterAll (cubic's P3).
  • No other code changed. uploadFiles, statPath and 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.md is still open. Reply that c78050a fixed it and resolve the thread. The /ready gate needs every thread resolved.
  • Your /ready reached GitHub as C:/Program Files/Git/ready. Git Bash rewrites an argument that starts with / into a Windows path. Post /ready from the GitHub web UI, or use MSYS_NO_PATHCONV=1, once CI is green.

Verified

  • Diffed the PR against main at both heads: only the rewording and the afterAll cleanup differ.
  • CI at c78050a: docs, docs translations and mobile pass. check, test x5, web and benchmark were still running at 22:15 UTC. Cubic found no issues in the new commits. mergeable_state unstable is only the running checks, and there are no conflicts.

@kunalgoesbyken

Copy link
Copy Markdown
Contributor Author

spec / check went red on apps/testbed/tests/set-input-files.e2e.ts "should throw an error if the file does not exist". that's the ported playwright test, and it expects node's raw ENOENT: no such file or directory text, which my message had dropped.

fixed in ac044a5: statPath now returns node's error instead of undefined, and the setInputFiles message appends its text (...cannot search: ENOENT: no such file or directory, stat '<path>'). route.fulfill's check and message are unchanged.

Verified

  • e2e run --tag playwright tests/set-input-files.e2e.ts in the testbed: the does-not-exist test passes now. "should upload large file with relative path" fails locally only because my tmp dir and the repo are on different windows drives, before setInputFiles runs
  • vitest run tests/unit in packages/web: only the 5 windows-only install.test.ts failures that main has too
  • upload-actions.test.ts + routes.test.ts: 86 passed, 2 skipped (the posix EACCES cases)
  • tsc --noEmit, oxlint src tests clean

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

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

@kunalgoesbyken

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions

Copy link
Copy Markdown
Contributor

/ready did not add the Ready for Human Review label yet:

  • 3 comment(s) or review(s) without your 👍: 1, 2, 3

Fix these and comment /ready again. How the label works.

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[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. statPath now 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 for ENOENT: no such file or directory plus the path, and both are there. It also matches Playwright 1.65.1, which runs fs.promises.stat on each path in resolvePathsAndDirectoryForInputFiles and 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.fulfill behaves 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 /ready is needed this time.

Nits

  • packages/web/src/actions.ts: when a path runs through a regular file, Node says ENOTDIR, 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.ts and actions.test.ts pass at the head (128 tests).
  • Mutant: I put the old ${file} back in the message in place of Node's text, and 6 upload-actions tests failed. Reverted.
  • CI at ac044a5 is all green, including spec, which runs the testbed set-input-files.e2e.ts, plus check, the test matrix, web, benchmark and docs. Cubic found 0 issues. mergeable_state is clean.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 22, 2026
@okwasniewski
okwasniewski added this pull request to the merge queue Nov 22, 2026
Merged via the queue into e2e-inc:main with commit 6fdb1c2 Nov 22, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web: setInputFiles with a path that doesn't exist is ENGINE_FAILURE (exit 3)

2 participants