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

URL Incorrect path Issue #436

Merged
merged 2 commits into from
Feb 13, 2024
Merged

Conversation

itsmevichu
Copy link
Contributor

@itsmevichu itsmevichu commented Feb 13, 2024

#Issue No. JuyterLab-#12768

Solution:

This 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()

Copy link

welcome bot commented Feb 13, 2024

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@JasonWeill
Copy link
Contributor

@itsmevichu Thanks for opening this PR! This fix doesn't address the underlying issue, where both the LabHandler and the NotFoundHandler get invoked upon visiting a URL like /lab/workspaces-bad/…. In the case of a bad URL, one that doesn't correspond to a lab session or a file, we should only invoke NotFoundHandler once. Note that NotFoundHandler extends and calls LabHandler.

@itsmevichu
Copy link
Contributor Author

itsmevichu commented Feb 13, 2024

@JasonWeill Thanks for your quick response, I am seeing that both NotFoundHandler and LabHandler is invoked while accessing the bad URL, but the persisted state of the path_config is what causing the I suppose.
Please have a look into this

@JasonWeill
Copy link
Contributor

JasonWeill commented Feb 13, 2024

I tested this with the following URLs locally, as documented here: https://jupyterlab.readthedocs.io/en/stable/user/urls.html

  • /
  • /lab
  • /lab/tree/hello.ipynb
  • /lab/tree/myoutput/foo.ipynb
  • /lab/tree/demo.ipynb#Mysection
  • /lab/tree/demo.ipynb?#Mysection
  • /lab/workspaces/foo/tree/hello.ipynb?reset

All loaded as expected.

Incorrect paths, like by misspelling workspaces, produced errors that only persisted for one page view.

Great work @itsmevichu !

@JasonWeill JasonWeill added the bug label Feb 13, 2024
@itsmevichu
Copy link
Contributor Author

Thank you so much @JasonWeill 😉

@JasonWeill JasonWeill linked an issue Feb 13, 2024 that may be closed by this pull request
@JasonWeill JasonWeill merged commit f30fddb into jupyterlab:main Feb 13, 2024
27 checks passed
Copy link

welcome bot commented Feb 13, 2024

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@JasonWeill
Copy link
Contributor

This is now available in JupyterLab Server version 2.25.3: https://github.com/jupyterlab/jupyterlab_server/releases/tag/v2.25.3

Thanks again @itsmevichu for your contribution!

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.

Unable to Navigate Notebooks via URL: 'Path Not Found' Error
3 participants