Skip to content

Unclear error when frontmatter contains invalid colon #127

Description

@pedzed

Take the following file colon_correct.md:

---
title: "Assignment 1: Some Title"
---

# Hello world!

And take the following file colon_mistake.md:

---
title: Assignment 1: Some Title
---

# Hello world!

The latter is understandably wrong (which took me longer to realize than necessary), thus it should fail with a clear error message. It rather gives a cryptic traceback such as:

Traceback (most recent call last):
  File "PROJ_DIR/main.py", line 40, in main
    post = frontmatter.load(md_file)
  File "PROJ_DIR/.venv/lib/python3.14/site-packages/frontmatter/__init__.py", line 165, in load
    return loads(text, encoding, handler, **defaults)
  File "PROJ_DIR/.venv/lib/python3.14/site-packages/frontmatter/__init__.py", line 185, in loads
    metadata, content = parse(text, encoding, handler, **defaults)
                        ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "PROJ_DIR/.venv/lib/python3.14/site-packages/frontmatter/__init__.py", line 92, in parse
    fm_data = handler.load(fm)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions