decaporg / decaporg/decap-cms

Throw better error on duplicate frontmatter key

Open
#7,262 6 comments 2 reactions 1 assignee Claimed by @codeafridi View on GitHub
area: error-handling
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Is your feature request related to a problem? Please describe.**
Sometimes we commit frontmatter via git and it happens that we duplicate a key. This causes an error, but it's not clear at all what's the cause.

**Describe the solution you'd like**
Show a better error: which key in which file is duplicated. Possibly propose a fix to delete the extra line. If the lines are different, offer which one to keep.

**Describe alternatives you've considered**
If you somehow realize that keys are duplicated, you need to find and remove them, which can take some time.

**Example**
```yaml
---
title: Example post
description: Hello world!
title: This second title causes an error
---
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.