You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by "Kaap10 (via GitHub)" <gi...@apache.org> on 2026/10/23 07:48:59 UTC

[I] fix(dev): workspace-pytest hook crashes on Windows with FileNotFoundError for /dev/stdin and drops backslash paths [magpie]

Kaap10 opened a new issue, #1766:
URL: https://github.com/apache/magpie/issues/1766

   ### What's broken
   Commit `d23116e2` (#1764) updated the `workspace-pytest` pre-commit hook to selectively test only changed workspace members by piping changed paths to `tools/dev/ci-pytest-batches.py --changed-file /dev/stdin --paths`.
   
   On Windows (under Git Bash / MSYS2 with native Python), this breaks:
   1. `ci-pytest-batches.py` fails with `FileNotFoundError: [Errno 2] No such file or directory: '\\proc\\self\\fd\\0'` because `/dev/stdin` is a POSIX-only virtual path that native Windows Python cannot open with Win32 APIs, and `--changed-file -` is not supported.
   2. In `ci-pytest-batches.py`, path separators in `--changed-file` are not normalized from `\` to `/`. Any Windows-style paths fail `c.startswith(prefixes)`, causing `select()` to return `[]` and silently skip running tests for modified workspace packages.
   3. In `run-workspace-check.sh`, multi-line output from Windows Python contains CRLF (`\r\n`). In bash, `applicable=$(...)` retains `\r` on intermediate tokens (e.g. `tools/agent-guard\r`), causing `uv run --directory` to fail with `os error 123` (syntax error in filename).
   4. `test_a_change_behind_a_member_symlink_picks_the_member` in `test_ci_pytest_batches.py` fails on Windows with `WinError 1314` (privilege not held) because it lacks `try/except OSError: pytest.skip(...)`.
   
   ### Which layer
   - `tools/dev/ci-pytest-batches.py`
   - `tools/dev/run-workspace-check.sh`
   - `tools/dev/tests/test_ci_pytest_batches.py`
   
   ### How to reproduce
   On Windows, run the workspace check against a modified file:
   ```bash
   tools/dev/run-workspace-check.sh pytest "pytest --version" tools/agent-guard/src/agent_guard/__init__.py
   ```
   
   Traceback:
   ```text
   Traceback (most recent call last):
     File "tools/dev/ci-pytest-batches.py", line 236, in <module>
       raise SystemExit(main())
     File "tools/dev/ci-pytest-batches.py", line 219, in main
       for line in args.changed_file.read_text(encoding="utf-8").splitlines()
     File "pathlib.py", line 1027, in read_text
       with self.open(mode='r', encoding=encoding, errors=errors) as f:
   FileNotFoundError: [Errno 2] No such file or directory: '\\proc\\self\\fd\\0'
   ```
   
   Additionally, running `uv run --directory tools/dev --project . python -m pytest tests/test_ci_pytest_batches.py` on Windows raises:
   ```text
   FAILED tests/test_ci_pytest_batches.py::test_a_change_behind_a_member_symlink_picks_the_member
   OSError: [WinError 1314] A required privilege is not held by the client
   ```
   
   ### Expected vs actual
   - **Expected:** `run-workspace-check.sh` and `ci-pytest-batches.py` should portably accept changed files through `stdin` (via standard `-`) across Linux, macOS, and Windows without crashing, normalize backslashes so Windows path separators match package prefixes, strip `\r` in bash command substitution, and guard symlink tests against missing OS symlink privileges.
   - **Actual:** Crashes on Windows with `FileNotFoundError`, silently bypasses tests when backslash paths are passed, breaks bash subshell tokenization with `\r`, and fails unit tests on unprivileged Windows runners.
   
   ### Surface area (optional)
   Local `pre-commit run workspace-pytest`, local commit git hooks on Windows, and `tools/dev/ci-pytest-batches.py`.
   
   ### Environment (optional)
   Windows 10/11, Git Bash / MSYS2, Python 3.12 (native Windows CPython).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] fix(dev): workspace-pytest hook crashes on Windows with FileNotFoundError for /dev/stdin and drops backslash paths [magpie]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed issue #1766: fix(dev): workspace-pytest hook crashes on Windows with FileNotFoundError for /dev/stdin and drops backslash paths
URL: https://github.com/apache/magpie/issues/1766


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org