Skip to content

Exception when trying serve hidden file or directory #1563

@andrii-i

Description

@andrii-i

Issue jupyterlab/jupyterlab#17825 in JupyterLab describes an exception when trying serve hidden file or directory.

The refusal to serve hidden file or directory should probably be handled by jupyter-server without throwing Uncaught exception GET.

Copying the original content below as a part of Jupyter Frontends triaging group work.


Description

I use a pipx-installed JupyterLab. While working on a notebook that uses the pygithub package I occasionally see these errors on the terminal where the jupyter-lab command is running 1:

[W 2025-08-27 15:15:09.266 ServerApp] 404 GET /api/contents/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/github/Requester.py?content=0&hash=0&1756300509261 ([email protected]) 0.49ms referer=http://localhost:8888/lab/tree/arrow/stats/gh-arrow.ipynb
[I 2025-08-27 15:15:09.266 ServerApp] Refusing to serve hidden file or directory '/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/github/Requester.py', via 404 Error
[E 2025-08-27 15:15:09.266 ServerApp] Uncaught exception GET /api/contents/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/github/Requester.py?content=0&hash=0&1756300509261 (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/contents/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/github/Requester.py?content=0&hash=0&1756300509261', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/jupyter_server/services/contents/handlers.py", line 156, in get
        model = await ensure_async(
                ^^^^^^^^^^^^^^^^^^^
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/jupyter_core/utils/__init__.py", line 197, in ensure_async
        result = await obj
                 ^^^^^^^^^
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/jupyter_server/services/contents/filemanager.py", line 928, in get
        model = await self._file_model(
                ^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/jupyter_server/services/contents/filemanager.py", line 829, in _file_model
        model = self._base_model(path)
                ^^^^^^^^^^^^^^^^^^^^^^
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/jupyter_server/services/contents/filemanager.py", line 237, in _base_model
        raise web.HTTPError(404, four_o_four)
    tornado.web.HTTPError: HTTP 404: Not Found (file or directory does not exist: '.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/github/Requester.py')
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/tornado/web.py", line 1848, in _execute
        result = await result
                 ^^^^^^^^^^^^
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/jupyter_server/auth/decorator.py", line 73, in inner
        return await out
               ^^^^^^^^^
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/jupyter_server/services/contents/handlers.py", line 182, in get
        await self._finish_error(
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/jupyter_server/services/contents/handlers.py", line 114, in _finish_error
        self.write(message)
      File "/home/antoine/.local/pipx/venvs/jupyterlab/lib/python3.12/site-packages/tornado/web.py", line 964, in write
        raise RuntimeError("Cannot write() after finish()")
    RuntimeError: Cannot write() after finish()

Note that github/Requester.py is typically a module from pygithub. I have no idea why JupyterLab is trying to fetch it using HTTP.

Reproduce

  1. Install jupyterlab and pygithub using pipx:
$ pipx install jupyterlab --include-deps
$ pipx inject jupyterlab pygithub
  1. Start jupyter-lab in a terminal
  2. Create a new ipykernel-based notebook
  3. Paste the following code in a cell:
from github import Auth, Github
token = Auth.Token('xxx')  # intentionally invalid token
g = Github(auth=token)
repo = g.get_repo('apache/arrow')
  1. Run the cell

Expected behavior

Context

  • Operating System and version: Ubuntu 24.04
  • Browser and version: Firefox 142.0
  • JupyterLab version: 4.4.7 (installed using pipx)

Footnotes

  1. Not the JupyterLab error console, as my original wording might have confusingly implied

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions