Skip to content

main is red: AddFrontmatter writes DateTimeOffset/DateOnly/TimeOnly/Version as ~20-key mappings again because CallerValueSerializer lacks the #217 converter (7 tests fail) #223

Closed

Description

@matt-edmondson

What's wrong

Two PRs touched the serializers and their merge dropped a fix:

// Frontmatter/YamlSerializer.cs:65-70
private static readonly ISerializer CallerValueSerializer = new SerializerBuilder()
    .WithNamingConvention(NullNamingConvention.Instance)
    .ConfigureDefaultValuesHandling(DefaultValuesHandling.Preserve)
    .WithQuotingNecessaryStrings(quoteYaml1_1Strings: true)
    .WithEventEmitter(next => new EdgeWhitespaceQuotingEventEmitter(next))
    .Build();   // no .WithTypeConverter(new InvariantScalarTypeConverter())

AddFrontmatter, ReplaceFrontmatter, SerializeFrontmatter and the insert-into-header path (TryInsertIntoHeader) all use CallerValueSerializer. They are called from Frontmatter.cs:235, :290, :330 and :377. As a result, #217 has regressed in every public writer.

Reproduction

Running dotnet test at 38c7c3c gives 399 tests total, 7 failed, all in InvariantScalarTypeTests:

  • AddFrontmatter_DateTimeOffset_IsWrittenAsAnIsoTimestamp
  • AddFrontmatter_DateOnly_IsWrittenAsAnIsoDate
  • AddFrontmatter_TimeOnly_IsWrittenAsAQuotedInvariantTime (×2)
  • AddFrontmatter_Version_IsWrittenAsItsText (×2)
  • AddFrontmatter_IntoAnExistingHeader_WritesTheValueAsAScalar
Frontmatter.AddFrontmatter("---\ntitle: Hello\n---\nBody\n",
    new() { ["date"] = new DateTimeOffset(2024, 1, 15, 10, 30, 0, TimeSpan.FromHours(2)) });

Expected:

date: 2024-01-15T10:30:00.0000000+02:00

Actual output is a mapping of about 20 keys:

date:
  DateTime: 2024-01-15T10:30:00.0000000
  UtcDateTime: 2024-01-15T08:30:00.0000000Z
  ...
  Year: 2024

Values inside lists are affected the same way.

Why it matters

  • main fails its own regression tests, so the next CI run and release are blocked.
  • Any consumer that passes a date or version writes garbage frontmatter.

Suggested fix / acceptance criteria

  • Add .WithTypeConverter(new InvariantScalarTypeConverter()) to CallerValueSerializer. Trying that one line locally took the suite to 399/399.
  • Preferably, build both serializers from one shared base builder, so the next option added to one cannot drift from the other.
  • All InvariantScalarTypeTests pass on main.

Activity

  1. added
    bug
    on Oct 31, 2026
  2. matt-edmondson commented on Oct 31, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

  3. added 5 commits that reference this issue on Oct 31, 2026
    ebc7e80
    9b77d60
    31fb0ff
    0ffd22a
    9172dd8
  4. added 5 commits that reference this issue on Nov 4, 2026
    3633e38
    15dcc83
    5c6bfd4
    b192b46
    7e32b25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions