Skip to content

Fix resolvePath handling for home-relative paths#1670

Open
MUFFANUJ wants to merge 5 commits into
jupyter-server:mainfrom
MUFFANUJ:fixTildaResolution
Open

Fix resolvePath handling for home-relative paths#1670
MUFFANUJ wants to merge 5 commits into
jupyter-server:mainfrom
MUFFANUJ:fixTildaResolution

Conversation

@MUFFANUJ

Copy link
Copy Markdown
Contributor

closes #1669

Expands ~ before resolving server contents paths so requests like ~/my-preferred-dir/foo.py resolve correctly when the expanded path is inside root_dir. Adds a regression test for /api/resolvePath while preserving the existing behavior of returning no result for paths outside the contents root.

@krassowski krassowski added the bug label Jun 30, 2026
Comment thread jupyter_server/services/contents/filemanager.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes /api/resolvePath for home-relative paths by expanding ~ before resolving server-scope content paths, so ~/… correctly resolves when the expanded filesystem path is inside root_dir, and remains unresolved when outside the contents root.

Changes:

  • Expand ~ (user home) in FileContentsManager.resolve_path prior to converting to an API path.
  • Add a regression test covering ~/… resolution under server scope.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
jupyter_server/services/contents/filemanager.py Expands ~ and validates expanded absolute paths against root_dir before resolving to an API path.
tests/services/kernels/test_api.py Adds a regression test ensuring /api/resolvePath resolves home-relative paths within the server root.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread jupyter_server/services/contents/filemanager.py Outdated
Comment thread tests/services/kernels/test_api.py Outdated
Comment thread jupyter_server/services/contents/filemanager.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@krassowski krassowski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@krassowski krassowski changed the title Fix resolvePath handling for home-relative paths Fix resolvePath handling for home-relative paths Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resolvePath does not resolve home-relative paths

3 participants