Skip to content

Fix attachFile() forwarding relative paths to the Node bridge - #6

Merged
smnandre merged 1 commit into
playwright-php:mainfrom
poman:fix/attachfile-relative-path
Aug 22, 2026
Merged

Fix attachFile() forwarding relative paths to the Node bridge#6
smnandre merged 1 commit into
playwright-php:mainfrom
poman:fix/attachfile-relative-path

Conversation

@poman

@poman poman commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #5

PlaywrightDriver::attachFile() passed the path string as-is to the Node bridge, which resolves relative paths against its own cwd (vendor/playwright-php/playwright/bin), not the PHP process cwd. Any path valid for file_exists() on the PHP side could fail with ENOENT on the Node side.

Resolves the path via realpath() before it crosses the process boundary, and throws a clear DriverException when the path does not exist instead of a confusing bridge-side ENOENT.

Testing

  • Reproduced the bug on main: relative-path attachFile() fails with ENOENT: no such file or directory, stat 'upload.txt'.
  • Added tests/Driver/AttachFileRelativePathTest.php (wired into a new "Regression tests" phpunit suite) covering both the success path and the missing-file error path — verified green with the fix, verified it reproduces the original failure without it.
  • php-cs-fixer --dry-run clean; phpstan analyse shows only 3 pre-existing, unrelated errors (same on main before this change).

@smnandre

Copy link
Copy Markdown
Member

Thank you @poman and sorry for the delay

@smnandre
smnandre merged commit 5ceb193 into playwright-php:main Aug 22, 2026
4 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.

attachFile() forwards relative paths to the Node bridge, which resolves them against its own cwd

2 participants