{"record":{"id":"16c99df334a7fca3","repo":"golangci/golangci-lint","slug":"failed-to-process-files-w","errorCode":null,"errorMessage":"failed to process files: %w","messagePattern":"failed to process files: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/fmt.go","lineNumber":122,"sourceCode":"\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...\")\n\n\terr := c.runner.Run(paths)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to process files: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (c *fmtCommand) persistentPostRun(_ *cobra.Command, _ []string) {\n\tif c.runner.ExitCode() != 0 {\n\t\tos.Exit(c.runner.ExitCode())\n\t}\n}\n\nfunc cleanArgs(args []string) []string {\n\tif len(args) == 0 {\n\t\treturn []string{\".\"}\n\t}\n\n\tvar expanded []string\n\tfor _, arg := range args {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/fmt.go#L104-L140","documentation":"fmt's execute step calls c.runner.Run(paths) which walks the given paths, applies the enabled formatters, and (optionally) writes or diffs the results. Any failure during this processing phase is wrapped as \"failed to process files\".","triggerScenarios":"Running `golangci-lint fmt` where the runner fails while walking paths (unreadable dirs/files, permission errors) or an individual formatter crashes/errors on some Go source.","commonSituations":"Formatting files with syntax errors that a formatter cannot parse; unreadable directories (permissions); filesystem errors; a formatter panicking on unusual code.","solutions":["Read the wrapped cause to find the specific file or formatter that failed.","Fix Go syntax errors in the reported files (formatters require parseable source).","Check file/directory read-write permissions for the paths passed.","Exclude problematic generated/vendored files via formatters.exclusions and re-run."],"exampleFix":"// before\ngolangci-lint fmt ./broken/   # contains malformed .go file\n// after\ngofmt -l ./broken/            # locate the syntax error, fix it, then re-run fmt","handlingStrategy":"validation","validationCode":"// ensure all target files parse before formatting\nfor _, f := range goFiles {\n  if _, err := parser.ParseFile(token.NewFileSet(), f, nil, parser.ParseComments); err != nil {\n    return fmt.Errorf(\"unparseable file %s: %w\", f, err)\n  }\n}\n// ensure paths are readable\nif err := filepath.Walk(root, func(p string, info os.FileInfo, err error) error {\n  if err != nil { return err }\n  return nil\n}); err != nil { return err }","typeGuard":null,"tryCatchPattern":"if err := fmtCmd.Run(); err != nil {\n  if strings.Contains(err.Error(), \"failed to process files\") {\n    log.Fatalf(\"fix the offending file/formatter: %v\", errors.Unwrap(err))\n  }\n  return err\n}","preventionTips":["Run `gofmt -l`/`go build ./...` first to catch syntax errors before formatting.","Exclude generated and vendored code via formatters.exclusions.","Check permissions on target directories, especially in CI with restricted users.","Format in small batches to isolate which file triggers a formatter failure."],"tags":["golangci-lint","formatters","file-processing"],"backgroundTag":"formatter-file-processing-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}