Skip to content

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

Open
poman wants to merge 1 commit into
playwright-php:mainfrom
poman:fix/attachfile-relative-path
Open

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

Conversation

@poman

@poman poman commented Jul 7, 2026

Copy link
Copy Markdown

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).

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

1 participant