From f26c1a059442c435451cab19702a6fb99f17953a Mon Sep 17 00:00:00 2001 From: Burt Holzman Date: Tue, 12 Mar 2024 17:33:43 -0500 Subject: [PATCH] Don't crash on invalid JSON in page_config (#1403) (#1404) --- jupyter_server/config_manager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jupyter_server/config_manager.py b/jupyter_server/config_manager.py index 87480d7609..30d52b5bd8 100644 --- a/jupyter_server/config_manager.py +++ b/jupyter_server/config_manager.py @@ -103,7 +103,10 @@ def get(self, section_name: str, include_root: bool = True) -> dict[str, t.Any]: for path in paths: if os.path.isfile(path): with open(path, encoding="utf-8") as f: - recursive_update(data, json.load(f)) + try: + recursive_update(data, json.load(f)) + except json.decoder.JSONDecodeError: + self.log.warn("Invalid JSON in %s, skipping", path) return data def set(self, section_name: str, data: t.Any) -> None: