Skip to content

[patch] Keep both values when two keys standardize to the same name - #156

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/136-standard-naming-collisions
Sep 28, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/136-standard-naming-collisions

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #136

Problem

NameStandardizer.StandardizePropertyNames wrote each renamed property with standardizedFrontmatter[name] = value. When two keys resolved to the same standard name, the later one overwrote the earlier one without any warning. With the default options, a document carrying both author and creator lost its author.

Change

All in Frontmatter/NameStandardizer.cs:

  • Name lookup extracted: working out a key's standard name (standard-name lower-casing, cache, known mappings, normalized match) now lives in GetStandardName. The rules are the same as before.
  • Rename only when free: a key is renamed only when its standard name is free, meaning it hasn't already been written and isn't the exact name of a key still to come. Otherwise the key keeps its original name. The lower-casing branch (Title → title) goes through the same guard.

Tests

  • Added StandardNamingCollisionTests. It covers the three rows in the issue, plus the alias-before-standard-name order and a check that a lone alias is still renamed.
  • With NameStandardizer.cs reverted, the four collision tests fail. The lone-alias test passes either way, as expected.
  • With the fix, all 189 tests pass on net10.0.

Notes

🤖 Generated with Claude Code

https://claude.ai/code/session_01KrGyxYxnoFgAkP1ENResCJ


Generated by Claude Code

matt-edmondson and others added 2 commits September 27, 2026 17:26
NameStandardizer wrote each renamed property with a plain indexer, so when
two keys resolved to one standard name (author + creator, Title + title) the
later silently overwrote the earlier. With the default options a document
carrying both author and creator lost its author.

A key is now renamed only when its standard name is free: not already
written and not the exact name of a key still to come. Otherwise it keeps
its original name. The lower-casing branch goes through the same guard.

Fixes #136

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KrGyxYxnoFgAkP1ENResCJ
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standard naming silently drops a property's value when another key standardizes to the same name (e.g. author + creator, Title + title)

1 participant