Attempting to open a markdown file with empty frontmatter in Jupyter Lab raises an AttributeError. E.g., consider the simple document.
---
---
This file has empty frontmatter.
Loading the yaml frontmatter returns None, and it is not possible to open the notebook. Adding a dummy variable resolves the issue because the frontmatter is not None. If there is no frontmatter block, the Python representation presumably defaults to an empty dict which avoids the error.
[W <datetime> ServerApp] wrote error: "'NoneType' object has no attribute 'get'"
Traceback (most recent call last):
File "/.../jupytext/contentsmanager.py", line 217, in get
model["content"] = reads(
File "/.../jupytext/jupytext.py", line 367, in reads
format_name = read_format_from_metadata(text, ext) or fmt.get("format_name")
File "/.../jupytext/formats.py", line 297, in read_format_from_metadata
metadata = read_metadata(text, ext)
File "/.../jupytext/formats.py", line 284, in read_metadata
header.get("jupytext", {})
AttributeError: 'NoneType' object has no attribute 'get'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/.../tornado/web.py", line 1786, in _execute
result = await result
File "/.../jupyter_server/services/contents/handlers.py", line 122, in get
self.contents_manager.get(
File "/.../jupytext/contentsmanager.py", line 230, in get
raise HTTPError(500, str(err))
tornado.web.HTTPError: HTTP 500: Internal Server Error ('NoneType' object has no attribute 'get')
This is on macOS 13.3.1 with Python 3.10 and the following dependencies.
Attempting to open a markdown file with empty frontmatter in Jupyter Lab raises an
AttributeError
. E.g., consider the simple document.Loading the yaml frontmatter returns
None
, and it is not possible to open the notebook. Adding a dummy variable resolves the issue because the frontmatter is notNone
. If there is no frontmatter block, the Python representation presumably defaults to an emptydict
which avoids the error.This is on macOS 13.3.1 with Python 3.10 and the following dependencies.