{"record":{"id":"34c5e6f80bf02302","repo":"golangci/golangci-lint","slug":"settings-key-q-must-be-valid-analyzer-name-valid","errorCode":null,"errorMessage":"settings key %q must be valid analyzer name, valid analyzers: %v","messagePattern":"settings key %q must be valid analyzer name, valid analyzers: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/goanalysis/linter.go","lineNumber":171,"sourceCode":"\n\t\tif err := f.Value.Set(valueToString(v)); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set analyzer setting %q with value %q: %w\", k, v, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (lnt *Linter) configure() error {\n\tanalyzersMap := map[string]*analysis.Analyzer{}\n\tfor _, a := range lnt.analyzers {\n\t\tanalyzersMap[a.Name] = a\n\t}\n\n\tfor analyzerName, analyzerSettings := range lnt.cfg {\n\t\ta := analyzersMap[analyzerName]\n\t\tif a == nil {\n\t\t\treturn fmt.Errorf(\"settings key %q must be valid analyzer name, valid analyzers: %v\",\n\t\t\t\tanalyzerName, lnt.allAnalyzerNames())\n\t\t}\n\n\t\tif err := lnt.configureAnalyzer(a, analyzerSettings); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to configure analyzer %s: %w\", analyzerName, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (lnt *Linter) preRun(lintCtx *linter.Context) error {\n\tif err := analysis.Validate(lnt.analyzers); err != nil {\n\t\treturn fmt.Errorf(\"failed to validate analyzers: %w\", err)\n\t}\n\n\tif err := lnt.configure(); err != nil {\n\t\treturn fmt.Errorf(\"failed to configure analyzers: %w\", err)","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/goanalysis/linter.go#L153-L189","documentation":"Raised by Linter.configure in golangci-lint when a key in the settings map (lnt.cfg) does not match any registered analyzer name. The library builds an analyzersMap from all enabled analyzers and rejects unknown keys, listing the valid analyzer names. It guards against misconfigured settings sections that would otherwise be silently ignored.","triggerScenarios":"A .golangci.yml settings (or golangci-lint config) block whose top-level key is not a real analyzer name — e.g. a misspelled analyzer, a linter that was removed/renamed, or settings placed under a wrong section.","commonSituations":"Upgrading golangci-lint where a linter was deprecated/renamed (old settings key left behind), typos like `gosimple` vs `staticcheck` merges, or copy-pasted config from another project with different enabled linters.","solutions":["Rename the settings key to one of the valid analyzers listed in the error message","Remove the stale settings block for a linter that no longer exists or is not enabled","Run `golangci-lint help linters` to confirm the exact analyzer name","If a linter was renamed in a newer version, migrate the settings to the new name"],"exampleFix":"# before (.golangci.yml)\nsettings:\n  golint:\n    min-confidence: 0.8\n# after\nsettings:\n  revive:\n    min-confidence: 0.8","handlingStrategy":"validation","validationCode":"validNames := map[string]bool{\"staticcheck\": true, \"revive\": true /* ... */}\nfor key := range cfg.Settings {\n    if !validNames[key] {\n        return fmt.Errorf(\"settings key %q is not a valid analyzer name\", key)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := golangciRun(cfg); err != nil {\n    if strings.Contains(err.Error(), \"must be valid analyzer name\") {\n        fmt.Fprintf(os.Stderr, \"unknown analyzer in settings: %v\\n\", err)\n        os.Exit(1)\n    }\n    return err\n}","preventionTips":["After upgrading golangci-lint, diff settings keys against `golangci-lint help linters`","Remove settings for disabled/removed linters instead of leaving them dormant","Copy analyzer names exactly from documentation, not from memory"],"tags":["golangci-lint","configuration","unknown-key"],"backgroundTag":"unknown-config-key","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}