Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Navigate Notebooks via URL: 'Path Not Found' Error #434

Closed
gnadrault opened this issue Jan 26, 2024 · 3 comments · Fixed by #436
Closed

Unable to Navigate Notebooks via URL: 'Path Not Found' Error #434

gnadrault opened this issue Jan 26, 2024 · 3 comments · Fixed by #436
Labels

Comments

@gnadrault
Copy link

Description

When attempting to open a specific notebook in JupyterLab using the file path URL (e.g., http://127.0.0.1:8888/lab/tree/work/my_notebook.ipynb), a popup with the error message "Path Not Found" appears. Consequently, the notebook fails to open.

image

Reproduce

  1. Start an instance of JupyterLab, I use the docker image jupyter/scipy-notebook:lab-4.0.7
  2. Create a new notebook
  3. Navigate to JupyterLab with the URL (e.g., http://127.0.0.1:8888/lab/tre) providing a bad path. Observe the error message "Path Not Found" is displayed.
  4. Attempt to navigate to the previously created notebook using the URL (e.g., http://127.0.0.1:8888/lab/tree/work/my_notebook.ipynb). Notice that the same "Path Not Found" error persists, making navigation to the notebook with the URL impossible.

Expected behavior

After providing a valid path in the URL, such as the path of a previously created notebook, the user should be able to navigate to the notebook without encountering a "Path Not Found" error.

Context

  • Operating System and version: Windows 10, WSL Ubuntu 22.04, Docker Desktop
  • Browser and version: Chrome 120
  • JupyterLab version: version 4.0.7, using jupyter/scipy-notebook:lab-4.0.7 docker image
Command Line Output No error message in the output
Browser Output
Showing error: {message: 'The path: /lab/tre was not found. JupyterLab redirected to: /'}message: "The path: /lab/tre was not found. JupyterLab redirected to: /"[[Prototype]]: Object
@gnadrault gnadrault added the bug label Jan 26, 2024
Copy link

welcome bot commented Jan 26, 2024

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@JasonWeill
Copy link
Contributor

This is a duplicate of jupyterlab/jupyterlab#12768, but I'm going to leave it open, because even though the JupyterLab issue was opened first, the problem is almost certainly in this regular expression in JupyterLab Server:

MASTER_URL_PATTERN = (
r"/(?P<mode>{}|doc)(?P<workspace>/workspaces/[a-zA-Z0-9\-\_]+)?(?P<tree>/tree/.*)?"
)

In short, this does not capture solely valid URLs, such as those starting with /lab/tree. We need to intercept malformed paths after /lab/ to prevent this from occurring.

@itsmevichu
Copy link
Contributor

itsmevichu commented Feb 13, 2024

Hi @JasonWeill, this above issue is because of directly referencing the dictionary object instead of creating a copy in Python. This leads to unintended shared state, where modifications made to the dictionary in one part of the code affect other references to the same dictionary object.

page_config = super().get_page_config()

This makes a direct access to the page_config dictionary object, meaning that appending the notFoundUrl to this page_config persists throughout the instance. As a consequence, accessing the correct URL after this operation continues to trigger the same error mentioning the same path which is captured while accessing the wrong path.

page_config["notFoundUrl"] = self.request.path

So, creating a shallow copy of the object fixes this issue.👇

page_config = super().get_page_config().copy()

I have raised a PR for this, please have a look into it.

@JasonWeill JasonWeill linked a pull request Feb 13, 2024 that will close this issue
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 a pull request may close this issue.

3 participants