{"record":{"id":"1a4d1c8385c13c94","repo":"golangci/golangci-lint","slug":"at-least-d-of-text-source-path-except-linte","errorCode":null,"errorMessage":"at least %d of (text, source, path[-except], linters) should be set","messagePattern":"at least (.+?) of \\(text, source, path\\[-except\\], linters\\) should be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/base_rule.go","lineNumber":62,"sourceCode":"\t}\n\n\t// Filtering by path counts as one condition, regardless how it is done (one or both).\n\t// Otherwise, a rule with Path and PathExcept set would pass validation\n\t// whereas before the introduction of path-except that wouldn't have been precise enough.\n\tif b.Path != \"\" || b.PathExcept != \"\" {\n\t\tnonBlank++\n\t}\n\n\tif b.Text != \"\" {\n\t\tnonBlank++\n\t}\n\n\tif b.Source != \"\" {\n\t\tnonBlank++\n\t}\n\n\tif nonBlank < minConditionsCount {\n\t\treturn fmt.Errorf(\"at least %d of (text, source, path[-except], linters) should be set\", minConditionsCount)\n\t}\n\n\treturn nil\n}\n\nfunc validateOptionalRegex(value string) error {\n\tif value == \"\" {\n\t\treturn nil\n\t}\n\n\t_, err := regexp.Compile(value)\n\treturn err\n}\n","sourceCodeStart":44,"sourceCodeEnd":76,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/config/base_rule.go#L44-L76","documentation":"BaseRule.Validate requires a linter-exclusion rule to set at least minConditionsCount (typically 2) of the fields: text, source, path/path-except, and linters. This prevents overly broad exclusion rules that would silently disable linting for too much code. If fewer fields are non-blank, the rule is considered too vague and validation fails.","triggerScenarios":"Running golangci-lint with a config whose linters.exclusions.rules entry has fewer than 2 of (text, source, path[-except], linters) set, e.g. a rule with only 'text' and no 'linters' or 'path'.","commonSituations":"Hand-editing the YAML config and adding an exclusion rule with only a message regex; copying a rule from docs and dropping the 'linters' key; typos like 'path-exept' leaving path unset.","solutions":["Add a second condition to the rule, most commonly a 'linters' list naming the linters the exclusion applies to","If the exclusion is unconditional, remove the rule entirely — a rule with fewer than 2 conditions is too broad","Check field names for typos (path-except vs pathExcept) that leave fields blank"],"exampleFix":"# before\nlinters:\n  exclusions:\n    rules:\n      - text: 'missing doc comment'\n# after\nlinters:\n  exclusions:\n    rules:\n      - text: 'missing doc comment'\n        linters:\n          - revive","handlingStrategy":"validation","validationCode":"for _, r := range cfg.Linters.Exclusions.Rules {\n\tcond := 0\n\tif r.Text != \"\" { cond++ }\n\tif r.Source != \"\" { cond++ }\n\tif len(r.Path) > 0 || len(r.PathsExcept) > 0 { cond++ }\n\tif len(r.Linters) > 0 { cond++ }\n\tif cond < 2 { return fmt.Errorf(\"exclusion rule needs >=2 conditions: %+v\", r) }\n}","typeGuard":null,"tryCatchPattern":"err := cfg.Validate(); if err != nil { log.Fatalf(\"invalid config: %v\", err) }","preventionTips":["Always pair 'text' or 'source' with a 'linters' list in exclusion rules","Run 'golangci-lint config verify' in CI before linting","Never delete the 'linters' key when copying exclusion examples"],"tags":["golangci-lint","config-validation","exclusions"],"backgroundTag":"invalid-linter-config","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}