{"record":{"id":"0096bc731a980c6c","repo":"golangci/golangci-lint","slug":"failed-to-get-file-s-lines-cache-w","errorCode":null,"errorMessage":"failed to get file %s lines cache: %w","messagePattern":"failed to get file (.+?) lines cache: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fsutils/linecache.go","lineNumber":40,"sourceCode":"// GetLine returns the index1-th (1-based index) line from the file on filePath\nfunc (lc *LineCache) GetLine(filePath string, index1 int) (string, error) {\n\tif index1 == 0 { // some linters, e.g. gosec can do it: it really means first line\n\t\tindex1 = 1\n\t}\n\n\tconst index1To0Offset = -1\n\trawLine, err := lc.getRawLine(filePath, index1+index1To0Offset)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(bytes.Trim(rawLine, \"\\r\")), nil\n}\n\nfunc (lc *LineCache) getRawLine(filePath string, index0 int) ([]byte, error) {\n\tfc, err := lc.getFileCache(filePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get file %s lines cache: %w\", filePath, err)\n\t}\n\n\tif index0 < 0 {\n\t\treturn nil, fmt.Errorf(\"invalid file line index0 < 0: %d\", index0)\n\t}\n\n\tif index0 >= len(fc) {\n\t\treturn nil, fmt.Errorf(\"invalid file line index0 (%d) >= len(fc) (%d)\", index0, len(fc))\n\t}\n\n\treturn fc[index0], nil\n}\n\nfunc (lc *LineCache) getFileCache(filePath string) (fileLinesCache, error) {\n\tloadedFc, ok := lc.files.Load(filePath)\n\tif ok {\n\t\treturn loadedFc.(fileLinesCache), nil\n\t}","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/fsutils/linecache.go#L22-L58","documentation":"Wrapping error in LineCache.getRawLine, called via GetLine: getFileCache(filePath) failed — underlying cause is usually the file byte cache failing to read the file (missing, unreadable) — so the requested line cannot be retrieved. The path and root cause are preserved via %w.","triggerScenarios":"Thrown at pkg/fsutils/linecache.go:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the source file exists and is readable","Check the wrapped underlying error for the file-read failure","Ensure the file was not removed while golangci-lint was running"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}