{"record":{"id":"c3a5b5cf70aedad0","repo":"golangci/golangci-lint","slug":"typo-q-and-correction-q-fields-should-not-be","errorCode":null,"errorMessage":"typo (%q) and correction (%q) fields should not be empty","messagePattern":"typo \\(%q\\) and correction \\(%q\\) fields should not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/golinters/misspell/misspell.go","lineNumber":136,"sourceCode":"\t\t\t\t\tNewText: []byte(diff.Corrected),\n\t\t\t\t}},\n\t\t\t}},\n\t\t})\n\t}\n\n\treturn nil\n}\n\nfunc appendExtraWords(replacer *misspell.Replacer, extraWords []config.MisspellExtraWords) error {\n\tif len(extraWords) == 0 {\n\t\treturn nil\n\t}\n\n\textra := make([]string, 0, len(extraWords)*2)\n\n\tfor _, word := range extraWords {\n\t\tif word.Typo == \"\" || word.Correction == \"\" {\n\t\t\treturn fmt.Errorf(\"typo (%q) and correction (%q) fields should not be empty\", word.Typo, word.Correction)\n\t\t}\n\n\t\tif strings.ContainsFunc(word.Typo, func(r rune) bool { return !unicode.IsLetter(r) }) {\n\t\t\treturn fmt.Errorf(\"the word %q in the 'typo' field should only contain letters\", word.Typo)\n\t\t}\n\t\tif strings.ContainsFunc(word.Correction, func(r rune) bool { return !unicode.IsLetter(r) }) {\n\t\t\treturn fmt.Errorf(\"the word %q in the 'correction' field should only contain letters\", word.Correction)\n\t\t}\n\n\t\textra = append(extra, strings.ToLower(word.Typo), strings.ToLower(word.Correction))\n\t}\n\n\treplacer.AddRuleList(extra)\n\n\treturn nil\n}\n","sourceCodeStart":118,"sourceCodeEnd":153,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/golinters/misspell/misspell.go#L118-L153","documentation":"misspell's extra-words setting lets users add custom typo→correction pairs. appendExtraWords validates each pair and rejects any entry whose typo or correction field is an empty string, because an empty rule is meaningless and would corrupt the replacer dictionary.","triggerScenarios":"Any entry in linters-settings.misspell.extra-words with typo: \"\" or correction: \"\" (missing key, blank YAML value, or null) while golangci-lint builds the misspell replacer.","commonSituations":"YAML entries where one side was left blank after editing; templated config generation that dropped a value; entries copied where the correction was intentionally empty to 'delete' a word.","solutions":["Fill in both typo and correction with non-empty single-word values for every extra-words entry.","Delete entries that have an empty side instead of leaving blank keys.","Run `golangci-lint config verify` to catch malformed settings early.","If you want to ignore a word, use ignore-rules instead of an empty correction."],"exampleFix":"# before\nextra-words:\n  - typo: \"langauge\"\n    correction: \"\"\n# after\nextra-words:\n  - typo: \"langauge\"\n    correction: \"language\"","handlingStrategy":"validation","validationCode":"for i, w := range extraWords {\n    if w.Typo == \"\" || w.Correction == \"\" {\n        return fmt.Errorf(\"extra-words[%d]: typo and correction must be non-empty\", i)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave typo/correction keys blank in YAML.","Use ignore-rules (not empty corrections) to skip words.","Lint your .golangci.yml with `golangci-lint config verify` in CI."],"tags":["golang","linter","misspell","validation"],"backgroundTag":"invalid-linter-config","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}