Skip to content

[BUG] YAML frontmatter parsing fails with unquoted colons in title #408

@phernandez

Description

@phernandez

Issue

Users are experiencing YAML parsing errors when creating notes with colons in the title field. The YAML parser interprets unquoted colons as key-value separators, causing the frontmatter to fail validation.

Error Examples

Example 1: Title with colon

---
title: L2 Governance Core (Split: Core)
---

Error:

Invalid YAML in frontmatter: mapping values are not allowed here
  in "<unicode string>", line 2, column 33:
    title: L2 Governance Core (Split: Core)
                                    ^

Example 2: Title starting with word + colon

---
title: Governance: Rootkeeper Manifest-Diff Prompt
---

Error:

Invalid YAML in frontmatter: mapping values are not allowed here
  in "<unicode string>", line 2, column 18:
    title: Governance: Rootkeeper Manifest-Diff Prompt
                     ^

Affected Tenants

  • Tenant: 78feaf4d-433e-b6a6-e855-b5c49d7c1975
  • Occurrences: 4 in past 24 hours
  • Timestamps:
    • 2025-10-28 12:00:00 UTC
    • 2025-10-28 11:58:27 UTC
    • 2025-10-28 05:25:39 UTC

Trace IDs

  • 019a2ab07c0b13c50f89e262c1f471cb
  • 019a2aaf0f6ba0a9cf7caa4421c13d67
  • 019a294773f4b629ca15345218d6674a

Root Cause

YAML specification requires values containing special characters (including colons) to be quoted. When the title contains a colon, the YAML parser interprets it as a key-value separator.

Proposed Solutions

Option 1: Auto-quote title values (Recommended)

Automatically quote the title field when writing frontmatter:

# In file_utils.py or wherever frontmatter is written
frontmatter_dict['title'] = title  # Current
# Change to:
frontmatter_dict['title'] = f'"{title}"' if ':' in title else title

Option 2: Validate and reject

Reject titles containing colons and provide clear error message to user.

Option 3: Escape colons

Escape colons in title values before writing YAML.

Option 4: Always quote all string values

Quote all string values in frontmatter regardless of content (safest but verbose):

---
title: "My Title"
permalink: "my-permalink"
---

User Impact

  • Users cannot create notes with colons in titles
  • Error messages are technical and confusing for non-technical users
  • Workaround: Manually edit YAML to add quotes or avoid colons

Priority

Medium - Affects user experience but has workaround. Not data loss issue.

Files to Modify

  • apps/api/src/basic_memory/file_utils.py - YAML frontmatter writing logic
  • Add test cases for titles with special characters

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions