Skip to content

fix(desktop): expect the host abspath in the linux system-browser test - #2555

Merged
abrichr merged 2 commits into
mainfrom
grok/fix-system-browser-linux-abspath
Nov 23, 2026
Merged

abrichr merged 2 commits into
mainfrom
grok/fix-system-browser-linux-abspath

Conversation

@abrichr

@abrichr abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member

Why

#2324's test_default_handler_receives_one_literal_url[linux] failed on Windows CI (desktop test / Python engine tests, windows-latest py3.11 and py3.12). _command() runs os.path.abspath on shutil.which("xdg-open"). On a Windows host, os.path.abspath("/usr/bin/xdg-open") is D:\usr\bin\xdg-open, so the test's hardcoded POSIX expectation did not match. The [win32] case passed. This is a test isolation issue, not a production bug on Linux (where abspath of an absolute POSIX path is a no-op).

What

The test now asserts against os.path.abspath of the injected xdg-open path, which is what _command() actually launches. Darwin still expects the hardcoded /usr/bin/open -- path (production does not abspath that helper). The [win32] case is unchanged. No production code change, and the case is not skipped on Windows.

Verification

  • pytest tests/test_engine/test_system_browser.py: 25 passed.
  • Locally simulated a Windows-style abspath (/usr/bin/xdg-open → D:\usr\bin\xdg-open); the updated expectation matches production.

_command() runs os.path.abspath on shutil.which("xdg-open"). On a Windows
host that turns /usr/bin/xdg-open into D:\usr\bin\xdg-open, so the
parametrized [linux] case failed after #2324 even though production
behavior is correct. Assert against os.path.abspath of the injected
path instead of a hardcoded POSIX string. The [win32] case is unchanged.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: db9839b

The test still proves the browser launches safely. Compared with the merge base, the diff touches only tests/test_engine/test_system_browser.py: +6/-2 lines in one test.

  • On POSIX hosts, os.path.abspath("/usr/bin/xdg-open") is /usr/bin/xdg-open. Linux and macOS CI therefore assert exactly the same list as before. Nothing is loosened there.
  • Every assertion that matters for safety is unchanged:
    • the launch is a single argv list passed to child_process.run, with no shell;
    • BROWSER="sh -c unsafe-command %s" is set and ignored;
    • a URL containing $(...), ; and quotes reaches the handler as one literal argument;
    • stdin, stdout and stderr are DEVNULL, with timeout=10.0 and check=True;
    • webbrowser.open raises if called.
  • The darwin case still expects the hardcoded /usr/bin/open --. The win32 case still expects startfile(url) only.
  • On a Windows host, the expectation now repeats the abspath call that _command() makes, so that call is checked only against itself there. Before this change the test asserted a literal POSIX path, which could not pass on Windows either. No check was lost.

Nit (not blocking): no test covers why _command() calls abspath, which is to absolutize a relative shutil.which result such as ./xdg-open. That was true before this PR as well. A small test where which returns a relative path and the launched argv[0] is absolute would cover it.

CI note: the one red job at this head, desktop test / Python engine tests (ubuntu-latest, py3.12), fails only on test_control_overlay_contract_sync.py ("openadapt-types 0.24.0 is required ... found 0.24.1"). That is the pin failure #2554 fixes, not this change. The windows-latest legs this PR targets do not appear in this head's checks. I could not see a Windows pass, so that result is unconfirmed. This PR changes only tests/, so it needs no Desktop version bump.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: 8c24f38

Cross-vendor delta check since my APPROVE at db9839b. The only new commit is a merge of origin/main. Against its merge base with main, the PR still changes exactly one file, packages/desktop/tests/test_engine/test_system_browser.py (+6/-2), the same test-isolation fix I reviewed before. There's no production change, and no safety assertion is weakened. The fix addresses the windows-latest failure in Packages 45089464389.

@abrichr
abrichr merged commit 6408a90 into main Nov 23, 2026
59 checks passed
@abrichr
abrichr deleted the grok/fix-system-browser-linux-abspath branch November 23, 2026 03:44
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.

1 participant