You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A complex (sequence or mapping) YAML key is rewritten as the literal text "System.Collections.Generic.List`1[System.Object]" #208
YamlSerializer.TryParseYamlObject turns every key into a string with pair.Key.ToString() (Frontmatter/YamlSerializer.cs:96). Nested mappings do the same via kvp.Key?.ToString() (:197, and in DeepCloneValue at :158). A YAML complex key deserializes to a List<object> or Dictionary<object, object>, whose ToString() is the .NET type name. The original key is lost, and every write path then saves that type name back into the document.
Failure scenario (verified against current main)
---
? [a, b]
: c
title: t
---
body
ExtractFrontmatter returns the key System.Collections.Generic.List`1[System.Object].
CombineFrontmatter writes System.Collections.Generic.List`1[System.Object]: c.
AddFrontmatter(doc, {draft: true}) writes the same corrupted key and adds draft: true.
? {x: 1} becomes System.Collections.Generic.Dictionary`2[System.Object,System.Object]: c.
The same happens for a complex key nested under another key, e.g. meta: { ? [1, 2] : pair }.
Suggested fix
When any key, at any depth, is not a scalar, treat the block as unreadable (return false). That reuses the existing "leave unreadable frontmatter alone" path in CombineFrontmatter and AddFrontmatter instead of inventing a string form.
Acceptance criteria
CombineFrontmatter and AddFrontmatter return a document with a complex key unchanged.
No output ever contains a .NET type name as a key.
Priority: Medium. Complex YAML keys are rare in frontmatter, but when one is present every write path (CombineFrontmatter, AddFrontmatter) silently replaces the original key with a .NET type name. That corrupts the document.
Area / suggested assignee:Frontmatter/YamlSerializer.cs: TryParseYamlObject (:96), the nested-mapping conversion (:197), and DeepCloneValue (:158). Owner: @matt-edmondson
Next step: the suggested fail-closed fix is right. Return false when any key at any depth is not a scalar, so the existing "leave unreadable frontmatter alone" path handles it. Add tests for a top-level sequence key, a top-level mapping key, and a nested complex key.
Activity
matt-edmondson commentedon Oct 20, 2026
Triage
CombineFrontmatter,AddFrontmatter) silently replaces the original key with a .NET type name. That corrupts the document.Frontmatter/YamlSerializer.cs:TryParseYamlObject(:96), the nested-mapping conversion (:197), andDeepCloneValue(:158). Owner: @matt-edmondsonGenerated by Claude Code