{"record":{"id":"7500130bd0c35c38","repo":"golangci/golangci-lint","slug":"invalid-file-line-index0-d-len-fc-d","errorCode":null,"errorMessage":"invalid file line index0 (%d) >= len(fc) (%d)","messagePattern":"invalid file line index0 \\((.+?)\\) >= len\\(fc\\) \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fsutils/linecache.go","lineNumber":48,"sourceCode":"\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}\n\n\tfileBytes, err := lc.fileCache.GetFileBytes(filePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't get file %s bytes from cache: %w\", filePath, err)\n\t}\n\n\tfc := bytes.Split(fileBytes, []byte(\"\\n\"))\n\tlc.files.Store(filePath, fileLinesCache(fc))","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/fsutils/linecache.go#L30-L66","documentation":"Bounds guard in LineCache.getRawLine: the requested 0-based line index is beyond the cached line count of the file, i.e. the reported position points past end-of-file. Usually means a linter issued an issue with a line number exceeding the file's length, or the file changed size after being cached.","triggerScenarios":"Thrown at pkg/fsutils/linecache.go:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the linter emitting out-of-range line numbers","Ensure the file is not truncated/modified during the run","Clear caches if the file changed while cached"],"exampleFix":null,"handlingStrategy":"validation","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"}