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

Invalid page_config.json can crash server #1403

Open
holzman opened this issue Mar 12, 2024 · 1 comment
Open

Invalid page_config.json can crash server #1403

holzman opened this issue Mar 12, 2024 · 1 comment
Labels

Comments

@holzman
Copy link
Contributor

holzman commented Mar 12, 2024

Description

An invalid page_config.json can cause a crash when connecting to a notebook server.

I'll have a PR in for this momentarily.

Reproduce

mkdir -p ~/.jupyter/labconfig
touch  ~/.jupyter/labconfig/page_config.json
jupyter lab

Connecting to the server generates a backtrace and 404 (it first throws an uncaught exception earlier in jupyterlab_server, but ignoring that since I've got a PR in for that, see jupyterlab/jupyterlab_server#444 and jupyterlab/jupyterlab_server#443):

     File "/opt/conda/lib/python3.9/site-packages/jupyterlab_server/handlers.py", line 161, in get
        page_config = self.get_page_config()
      File "/opt/conda/lib/python3.9/site-packages/jupyterlab_server/handlers.py", line 142, in get_page_config
        page_config, get_page_config(labextensions_path, settings_dir, logger=self.log)
      File "/opt/conda/lib/python3.9/site-packages/jupyterlab_server/config.py", line 144, in get_page_config
        static_page_config = get_static_page_config(logger=logger, level="all")
      File "/opt/conda/lib/python3.9/site-packages/jupyterlab_server/config.py", line 91, in get_static_page_config
        return cm.get("page_config")  # type:ignore[no-untyped-call]
      File "/opt/conda/lib/python3.9/site-packages/jupyter_server/services/config/manager.py", line 30, in get
        recursive_update(config, cm.get(section_name))
      File "/opt/conda/lib/python3.9/site-packages/jupyter_server/config_manager.py", line 106, in get
        with open(path, encoding="utf-8") as f:
      File "/opt/conda/lib/python3.9/json/__init__.py", line 293, in load
        return loads(fp.read(),
      File "/opt/conda/lib/python3.9/json/__init__.py", line 346, in loads
        return _default_decoder.decode(s)
      File "/opt/conda/lib/python3.9/json/decoder.py", line 337, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/opt/conda/lib/python3.9/json/decoder.py", line 355, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

We run jupyterhub and have fixed amounts of storage space per user (via PVCs in Kubernetes). If the user fills their storage completely, we've seen behavior where zero-length page_config.json files get generated.

Expected behavior

Ignore the invalid JSON and proceed.

Context

  • Operating System and version: Centos 7, Alma 8, 9
  • Browser and version: Firefox/Chrome
  • Jupyter Server version: 2.13.0
@holzman holzman added the bug label Mar 12, 2024
Copy link

welcome bot commented Mar 12, 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! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant