duplicate-key: a key written twice in one JSON object
error — fails the build
The same key appears twice inside one object of a JSON locale file. JSON.parse in JavaScript, encoding/json in Go and json in Python all keep the last value and drop the first without a warning, so one of the two strings is never shown. It is an error when the two values differ and a warning when they are identical (redundant, nothing lost).
What triggers it
// de.json
{
"inbox": {
"archive": "Archiv", // the folder name
"delete": "löschen",
"archive": "archivieren" // the action — this one wins
}
}Fixed
// de.json — one key per meaning
{
"inbox": {
"archive_folder": "Archiv",
"delete": "löschen",
"archive_action": "archivieren"
}
}Why it matters
The parsed file looks fine, every key-set check passes, and the lost string is invisible until someone notices the wrong word on screen. It usually comes from one English word with two meanings (a noun and a verb) sharing a key, and translators copy the duplicate into every locale: in one open-source mail client all eleven locale files repeated the same key.
How to fix it
Keep one entry. If the two values are different meanings, give each its own key in the source and every translation, and update the code that reads them. The finding names both line numbers.
How to silence it
--severity 'duplicate-key=warning' to stop it failing a build, or --ignore-keys 'path.to.key' for one key.
Check for this in CI
npx @shipi18n/cli check ./locales -s en
# SARIF for inline PR annotations:
npx @shipi18n/cli check ./locales -s en -r sarif -o shipi18n.sarifThe structural checks need no API key. Findings of this rule link back to this page from the SARIF helpUri.
Related rules
- invalid-json — broken JSON in a translation file
- orphan-key — translation keys that no longer exist in the source