Use pathlib.Path.as_uri to format browser open redirect files - #1682
Open
aadamowski wants to merge 1 commit into
Open
aadamowski wants to merge 1 commit into
aadamowski wants to merge 1 commit into
Conversation
aadamowski
marked this pull request as draft
July 22, 2026 00:12
aadamowski
marked this pull request as ready for review
July 22, 2026 00:13
Author
|
Rebase against Ran Unfortunately, looks like GitHub actions continuous integration infra for the project is currently broken, hence the failing checks (which segfault on spinup). I also observed some flaky tests which can spuriously fail on both my branch and on main (notably, |
The existing urljoin pattern constructs non-compliant file URIs containing a single leading slash on Unix platforms. This breaks system-level browser dispatching tools like xdg-open on strict desktop environments. Replacing the urljoin implementation with standard library pathlib methods ensures that valid, platform-aware file URLs are universally generated and logged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Uses
pathlib.Path.as_uri()to construct standards-compliant local file URLs for the browser redirect file utility.Details
The combination of
urljoin("file:", pathname2url(...))generates non-compliantfile:/home/...URI strings on Unix platforms. Strict POSIX URL handlers (such asxdg-openunder desktop environments like LXQt) fail to resolve this format as a local file, breaking automatic browser launch pipelines.Migrating this formatting layer to
pathlib.Path.as_uri()ensures robust, platform-aware URI compilation. This guarantees valid triple-slash formats (file:///...) for both the background subprocess execution thread and the terminal diagnostic logs.Testing
I've ran
pytestas documented in CONTRIBUTING.rst#running-tests.All tests pass, except for
tests/services/sessions/test_api.py::test_restart_kernel[jp_server_config0]which on my machine also fails with code on themainbranch, withassert 1 == 0. This seems to be a pre-existing broken test.