Skip to content

Frontmatter YAML: inline " - " in a plain scalar throws ParseFailure (seq_item_ind) #73

Closed

Description

@sc2ben

Summary

The YAML frontmatter parser throws error.ParseFailure on a plain scalar value that
contains an inline " - "
(space-hyphen-space). It mistokenizes the inline - as a
sequence-item indicator (seq_item_ind) and aborts, even though the hyphen is in the
middle of a value, not at the start of a line.

Minimal repro

---
description: prior notes - here.
---
body
$ zigmark --format frontmatter repro.md
(memory):2:28: error: unexpected token for 'key': .{ .id = .seq_item_ind, .loc = .{ .start = 26, .end = 28 } }
description: prior notes - here.
                           ^~
error: failed to parse frontmatter: error.ParseFailure
error: ParseFailure

Expected

description parses as the string prior notes - here.. In YAML, - is a
sequence-entry indicator only at the start of a node (line/indent); a hyphen inside a
plain scalar is ordinary text.

Isolation (what is / isn't the trigger)

  • ✅ Trigger: inline " - " in a plain scalar → ParseFailure.
  • ❌ Not parentheses: description: Aligned to the ISO 27701 (2025 revision). parses fine.
  • ❌ Not multi-entry lists: a major_revisions: sequence of 2+ complete mappings parses
    fine (each entry's fields intact).

Secondary: memory leak on the error path

On the ParseFailure path the DebugAllocator reports leaked allocations:

error(DebugAllocator): memory address 0x... leaked:

Impact / how it surfaced

Found via dogfooding in sc2in/corp: policypress (which parses policy frontmatter through
zigmark.Frontmatter.initFromMarkdown) could not render a Privacy Policy whose
extra.major_revisions[].description contained " - ". Because a mis-parse drops fields,
it can also surface downstream as misleading validation errors (e.g. policypress
reporting major_revisions "missing the 'version' field" when every entry has one). A
policy revision history is a core ISMS use case, so value prose with " - " is common.

Environment: zigmark dev (built from current main via the flake), --format frontmatter.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions