{"record":{"id":"ef3fcd28adec2d88","repo":"golangci/golangci-lint","slug":"invalid-preset-s","errorCode":null,"errorMessage":"invalid preset: %s","messagePattern":"invalid preset: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/linters_exclusions.go","lineNumber":48,"sourceCode":"}\n\nfunc (e *LinterExclusions) Validate() error {\n\tfor i, rule := range e.Rules {\n\t\tif err := rule.Validate(); err != nil {\n\t\t\treturn fmt.Errorf(\"error in exclude rule #%d: %w\", i, err)\n\t\t}\n\t}\n\n\tallPresets := []string{\n\t\tExclusionPresetComments,\n\t\tExclusionPresetStdErrorHandling,\n\t\tExclusionPresetCommonFalsePositives,\n\t\tExclusionPresetLegacy,\n\t}\n\n\tfor _, preset := range e.Presets {\n\t\tif !slices.Contains(allPresets, preset) {\n\t\t\treturn fmt.Errorf(\"invalid preset: %s\", preset)\n\t\t}\n\t}\n\n\treturn nil\n}\n\ntype ExcludeRule struct {\n\tBaseRule `mapstructure:\",squash\"`\n}\n\nfunc (e *ExcludeRule) Validate() error {\n\treturn e.BaseRule.Validate(excludeRuleMinConditionsCount)\n}\n","sourceCodeStart":30,"sourceCodeEnd":62,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/config/linters_exclusions.go#L30-L62","documentation":"LinterExclusions.Validate checks every entry in linters.exclusions.presets against the known set: comments, std-error-handling, common-false-positives, legacy. An unknown preset name fails with 'invalid preset'.","triggerScenarios":"Config with linters.exclusions.presets: [my-preset] or a misspelled preset name; v1 preset names that no longer exist in v2.","commonSituations":"Copying old v1 configs where preset sets differed; typos like 'false-positives' instead of 'common-false-positives'; inventing custom preset names (not supported).","solutions":["Replace the preset name with one of: comments, std-error-handling, common-false-positives, legacy","Remove the invalid preset and express the exclusions as explicit rules instead","Check docs at golangci-lint.run for the current preset list"],"exampleFix":"# before\nlinters:\n  exclusions:\n    presets:\n      - false-positives\n# after\nlinters:\n  exclusions:\n    presets:\n      - common-false-positives","handlingStrategy":"validation","validationCode":"var validPresets = []string{\"comments\",\"std-error-handling\",\"common-false-positives\",\"legacy\"}\nfor _, p := range cfg.Linters.Exclusions.Presets {\n\tif !slices.Contains(validPresets, p) {\n\t\treturn fmt.Errorf(\"invalid preset: %s\", p)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := exclusions.Validate(); err != nil { log.Fatalf(\"preset error: %v\", err) }","preventionTips":["Only use documented preset names","Re-check presets after major version upgrades","Verify config in CI"],"tags":["golangci-lint","config-validation","presets"],"backgroundTag":"invalid-exclusion-preset","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}