{"record":{"id":"9d35564332423227","repo":"golangci/golangci-lint","slug":"can-t-extract-issues-from-s-diff-output-q-w","errorCode":null,"errorMessage":"can't extract issues from %s diff output %q: %w","messagePattern":"can't extract issues from (.+?) diff output %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/goformatters/analyzer.go","lineNumber":47,"sourceCode":"\t\t\t\tinput, err := os.ReadFile(position.Filename)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unable to open file %s: %w\", position.Filename, err)\n\t\t\t\t}\n\n\t\t\t\toutput, err := formatter.Format(position.Filename, input)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"error while running %s: %w\", formatter.Name(), err)\n\t\t\t\t}\n\n\t\t\t\tif !bytes.Equal(input, output) {\n\t\t\t\t\tnewName := filepath.ToSlash(position.Filename)\n\t\t\t\t\toldName := newName + \".orig\"\n\n\t\t\t\t\tpatch := diff.Diff(oldName, input, newName, output)\n\n\t\t\t\t\terr = internal.ExtractDiagnosticFromPatch(pass, file, patch, logger)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"can't extract issues from %s diff output %q: %w\", formatter.Name(), patch, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn nil, nil\n\t\t},\n\t}\n}\n","sourceCodeStart":29,"sourceCodeEnd":56,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/goformatters/analyzer.go#L29-L56","documentation":"After formatting, if the file changed, golangci-lint computes a diff and tries to convert it into lint diagnostics via ExtractDiagnosticFromPatch. If that extraction fails, the patch and formatter name are wrapped in this error. It indicates the diff produced could not be mapped back to reportable issues.","triggerScenarios":"diff.Diff produces a patch for a changed file, then internal.ExtractDiagnosticFromPatch returns an error while parsing or mapping hunks to AST positions in the analyzer pass.","commonSituations":"Formatter output producing unusual diff shapes; files with CRLF/mixed encodings confusing the diff parser; upstream bug in the diff package for specific hunks; very large rewrites spanning whole files.","solutions":["Update golangci-lint (diff extraction bugs are frequently fixed upstream)","Run the formatter directly (gofmt/gofumpt -w) so the file is clean before linting","Normalize line endings (LF) and file encoding in the repo (.gitattributes: * text=auto eol=lf)","Temporarily exclude the problem file/formatter to unblock the run and report the bug"],"exampleFix":"# .gitattributes to normalize line endings\n# before: mixed CRLF/LF\n# after\n*.go text eol=lf","handlingStrategy":"fallback","validationCode":"// apply formatter directly to avoid diff extraction path\nout, err := exec.Command(\"gofmt\", \"-l\", \".\").Output()","typeGuard":null,"tryCatchPattern":"// fall back to pre-formatting files when extraction fails\nif strings.Contains(err.Error(), \"can't extract issues from\") {\n    // run formatter directly (gofmt -w) and re-lint\n}","preventionTips":["Normalize line endings via .gitattributes","Avoid exotic filenames (spaces, unicode)","Keep golangci-lint updated for diff fixes"],"tags":["golangci-lint","formatters","diff"],"backgroundTag":"patch-extraction-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}