{"record":{"id":"d3b339fae2bc9e86","repo":"golangci/golangci-lint","slug":"failed-to-create-meta-formatter-w","errorCode":null,"errorMessage":"failed to create meta-formatter: %w","messagePattern":"failed to create meta-formatter: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/fmt.go","lineNumber":100,"sourceCode":"\n\tloader := config.NewFormattersLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg, args)\n\n\terr := loader.Load(config.LoadOptions{CheckDeprecation: true, Validation: true})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"can't load config: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (c *fmtCommand) preRunE(_ *cobra.Command, _ []string) error {\n\tif c.cfg.GetConfigDir() != \"\" && c.cfg.Version != \"2\" {\n\t\treturn fmt.Errorf(\"invalid version of the configuration: %q\", c.cfg.Version)\n\t}\n\n\tmetaFormatter, err := goformatters.NewMetaFormatter(c.log, &c.cfg.Formatters, &c.cfg.Run)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create meta-formatter: %w\", err)\n\t}\n\n\tmatcher := processors.NewGeneratedFileMatcher(c.cfg.Formatters.Exclusions.Generated)\n\n\topts, err := goformat.NewRunnerOptions(c.cfg, c.opts.diff, c.opts.diffColored, c.opts.stdin)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"build walk options: %w\", err)\n\t}\n\n\tc.runner = goformat.NewRunner(c.log, metaFormatter, matcher, opts)\n\n\treturn nil\n}\n\nfunc (c *fmtCommand) execute(_ *cobra.Command, args []string) error {\n\tpaths := cleanArgs(args)\n\n\tc.log.Infof(\"Formatting Go files...\")","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/fmt.go#L82-L118","documentation":"In fmt's preRunE, goformatters.NewMetaFormatter (which sets up the selected formatters, their options and exclusions) failed. The wrapping \"failed to create meta-formatter\" indicates formatter settings could not be turned into runnable formatter instances.","triggerScenarios":"Running `golangci-lint fmt` where the `formatters` config section references an unknown formatter name, has invalid formatter options, or a formatter plugin fails to initialize.","commonSituations":"Typo in a formatter name (e.g. `gofumports` vs `gofumpt`); invalid options under a formatter's settings; a custom plugin formatter not registered/built into the binary.","solutions":["Read the wrapped cause: it identifies which formatter or option failed; fix that config entry.","Verify formatter names against `golangci-lint formatters` output for your version.","Ensure custom plugin formatters are built into the binary (via `golangci-lint custom`) before use.","Remove unknown formatter entries from the `formatters:` section."],"exampleFix":"// before (.golangci.yml)\nformatters:\n  enable: [gofmpt]\n// after\nformatters:\n  enable: [gofumpt]","handlingStrategy":"validation","validationCode":"// check formatter names are known before running fmt\nout, err := exec.Command(\"golangci-lint\", \"formatters\").CombinedOutput()\nif err != nil { return err }\nfor _, name := range cfg.Formatters.Enable {\n  if !strings.Contains(string(out), name) {\n    return fmt.Errorf(\"unknown formatter %q\", name)\n  }\n}","typeGuard":null,"tryCatchPattern":"if err := fmtCmd.Run(); err != nil {\n  if strings.Contains(err.Error(), \"failed to create meta-formatter\") {\n    log.Fatalf(\"check formatters section: %v\", errors.Unwrap(err))\n  }\n  return err\n}","preventionTips":["Cross-check formatter names with `golangci-lint formatters` for your version.","Use the config JSON schema in your editor to validate the formatters section.","Build plugin formatters into the binary via `golangci-lint custom` before referencing them.","Test config changes with `golangci-lint formatters` (a read-only listing) before fmt."],"tags":["golangci-lint","formatters","initialization"],"backgroundTag":"formatter-init-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}