{"record":{"id":"00e9c8d6a6d27361","repo":"golangci/golangci-lint","slug":"s-w-00e9c8","errorCode":null,"errorMessage":"%s: %w","messagePattern":"%s: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/result/processors/fixer.go","lineNumber":189,"sourceCode":"\t\tvar edits []diff.Edit\n\t\tfor linter := range linterToEdits {\n\t\t\tif _, found := excludedLinters[linter]; !found {\n\t\t\t\tedits = append(edits, linterToEdits[linter]...)\n\t\t\t}\n\t\t}\n\n\t\teditsByPath[path], _ = validateEdits(edits) // remove duplicates. already validated.\n\t}\n\n\tvar editError error\n\n\tvar formattedFiles []string\n\n\t// Now we've got a set of valid edits for each file. Apply them.\n\tfor path, edits := range editsByPath {\n\t\tcontents, err := p.fileCache.GetFileBytes(path)\n\t\tif err != nil {\n\t\t\teditError = errors.Join(editError, fmt.Errorf(\"%s: %w\", path, err))\n\t\t\tcontinue\n\t\t}\n\n\t\tout, err := diff.ApplyBytes(contents, edits)\n\t\tif err != nil {\n\t\t\teditError = errors.Join(editError, fmt.Errorf(\"%s: %w\", path, err))\n\t\t\tcontinue\n\t\t}\n\n\t\t// Try to format the file.\n\t\tout = p.formatter.Format(path, out)\n\n\t\tif err := os.WriteFile(path, out, filePerm); err != nil {\n\t\t\teditError = errors.Join(editError, fmt.Errorf(\"%s: %w\", path, err))\n\t\t\tcontinue\n\t\t}\n\n\t\tformattedFiles = append(formattedFiles, path)","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/result/processors/fixer.go#L171-L207","documentation":"During the fix application phase, the fixer reads each affected file's bytes from its cache. If GetFileBytes fails (file unreadable, removed, or not cached) the error is joined into an aggregate editError prefixed by the file path, and the fixer continues with other files. This produces a multi-error report of which files could not be fixed.","triggerScenarios":"process reaches the apply loop and fileCache.GetFileBytes(path) returns an error for a file that had valid edits — typically because the file was deleted or is unreadable on disk after analysis.","commonSituations":"Files deleted by an earlier linter's fix in the same run; permission-restricted files; files removed by concurrent processes (e.g. codegen running during --fix); symlinks pointing to missing targets.","solutions":["Restore the missing/unreadable file listed in the error, then re-run with --fix","Check file permissions for the user running golangci-lint","Avoid running code generators concurrently with golangci-lint --fix","Re-run analysis so the file cache is consistent with disk state"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: verify all fix-target files are readable before running --fix\nfor _, path := range targetFiles {\n    if _, err := os.ReadFile(path); err != nil {\n        return fmt.Errorf(\"cannot fix unreadable file %s: %w\", path, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"fixed, err := fixer.Process(issues)\nif err != nil {\n    log.Printf(\"some files could not be fixed: %v\", err) // errors.Join aggregate\n    // inspect per-path segments of the joined error\n}","preventionTips":["Don't run codegen concurrently with golangci-lint --fix","Ensure the lint user has read/write access to the repo","Re-run linting after any files are deleted or moved"],"tags":["file-io","autofix","golangci-lint"],"backgroundTag":"file-read-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}