{"record":{"id":"508183456764ed22","repo":"golangci/golangci-lint","slug":"invalid-formatter-q","errorCode":null,"errorMessage":"invalid formatter %q","messagePattern":"invalid formatter %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/goformatters/meta_formatter.go","lineNumber":27,"sourceCode":"\t\"github.com/golangci/golangci-lint/v2/pkg/config\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/goformatters/gci\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/goformatters/gofmt\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/goformatters/gofumpt\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/goformatters/goimports\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/goformatters/golines\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/goformatters/swaggo\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/logutils\"\n)\n\ntype MetaFormatter struct {\n\tlog        logutils.Log\n\tformatters []Formatter\n}\n\nfunc NewMetaFormatter(log logutils.Log, cfg *config.Formatters, runCfg *config.Run) (*MetaFormatter, error) {\n\tfor _, formatter := range cfg.Enable {\n\t\tif !IsFormatter(formatter) {\n\t\t\treturn nil, fmt.Errorf(\"invalid formatter %q\", formatter)\n\t\t}\n\t}\n\n\tm := &MetaFormatter{log: log}\n\n\tif slices.Contains(cfg.Enable, gofmt.Name) {\n\t\tm.formatters = append(m.formatters, gofmt.New(&cfg.Settings.GoFmt))\n\t}\n\n\tif slices.Contains(cfg.Enable, gofumpt.Name) {\n\t\tm.formatters = append(m.formatters, gofumpt.New(&cfg.Settings.GoFumpt, runCfg.Go))\n\t}\n\n\tif slices.Contains(cfg.Enable, goimports.Name) {\n\t\tm.formatters = append(m.formatters, goimports.New(&cfg.Settings.GoImports))\n\t}\n\n\tif slices.Contains(cfg.Enable, swaggo.Name) {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/goformatters/meta_formatter.go#L9-L45","documentation":"NewMetaFormatter validates every name in the formatters.enable config list via IsFormatter and rejects the first one it does not recognize. It means golangci-lint was asked to enable a formatter that either does not exist or is not registered in this build.","triggerScenarios":"A formatters.enable entry in .golangci.yml (e.g. 'prettier', a misspelled 'gofumpt', or a plugin formatter) that IsFormatter does not know. Called from preRunE / NewRunner during startup.","commonSituations":"Typo in the enable list, copying config from another tool (gofmt vs gofumps), using a formatter added in a newer golangci-lint version than installed, or expecting a custom plugin formatter to be auto-registered without a plugin build.","solutions":["Run 'golangci-lint formatters' to list valid formatter names and correct the typo in formatters.enable","Upgrade golangci-lint if the formatter exists only in a newer release","Remove the unsupported formatter from formatters.enable","For custom formatters, build golangci-lint with the plugin properly registered"],"exampleFix":"# before\nformatters:\n  enable:\n    - gofumptt\n# after\nformatters:\n  enable:\n    - gofumpt","handlingStrategy":"validation","validationCode":"// Before writing config, verify each formatter name is known:\n// golangci-lint formatters   # list valid formatter names\nconst validFormatters = map[string]bool{\"gofmt\": true, \"gofumpt\": true, \"gci\": true, \"goimports\": true, \"golines\": true}\nfor _, f := range cfg.Formatters.Enable {\n    if !validFormatters[f] {\n        return fmt.Errorf(\"unknown formatter %q — see 'golangci-lint formatters'\", f)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := runner.New(); err != nil {\n    var cfgErr *configError\n    if strings.Contains(err.Error(), \"invalid formatter\") {\n        fmt.Fprintln(os.Stderr, \"fix formatters.enable in .golangci.yml; run 'golangci-lint formatters' for names\")\n        os.Exit(1)\n    }\n    return err\n}","preventionTips":["Run 'golangci-lint formatters' after editing formatters.enable","Match formatter names exactly (gofumpt, not gofumps/prettier)","Check formatter availability against your pinned golangci-lint version before upgrading configs"],"tags":["golangci-lint","configuration","formatter"],"backgroundTag":"unknown-formatter-configured","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}