decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

fix(frontmatter): improve duplicate frontmatter key error handling

Open codeafridi opened this issue 1 month ago • 2 comments

Summary

I fixed an issue with YAML frontmatter where duplicate keys caused a vague error that didn’t point to the real problem. I added a simple check that detects repeated keys and shows a clear message with the key name and line number which points to the file

Test plan

-ensured normal frontmatter files still parse correctly. -ran the formatter manually to confirm it now identifies the duplicated key. -verified that the error message displays the correct key and the line where it occurs.

Checklist

Please add a x inside each checkbox:

codeafridi avatar Dec 08 '25 13:12 codeafridi

Thanks for the feedback. ill update it now.

  • i will remove the thrown error and replace it with a simple console.log warn without a stack trace.
  • i will include the file path, key name, and line number in the warning message so it’s clear which entry is affected. -then limit the detection to the currently opened entry, so warnings don’t appear for every file in the collection.
  • yes cms users shouldn’t see this so i will keep it in the console only for developers.

I’ll push the changes soon.

codeafridi avatar Dec 08 '25 14:12 codeafridi

Alright now I get it. I'll now

-parse yaml structure properly -track full key paths -only warn when the same key appears in the same parent scope -ennsuring all existing tests pass before pushing the update

codeafridi avatar Dec 09 '25 02:12 codeafridi

do tell if any changes are needed.

codeafridi avatar Dec 15 '25 09:12 codeafridi