{"record":{"id":"c5f98a1d6d86601c","repo":"golangci/golangci-lint","slug":"invalid-file-line-index0-0-d","errorCode":null,"errorMessage":"invalid file line index0 < 0: %d","messagePattern":"invalid file line index0 < 0: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fsutils/linecache.go","lineNumber":44,"sourceCode":"\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}\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)","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/fsutils/linecache.go#L26-L62","documentation":"Range guard in LineCache.getRawLine: the computed 0-based line index is negative, meaning a caller passed index1 < 1 to GetLine (after the -1 offset). Indicates an internal/upper-layer bug where a linter emitted a zero or negative line number.","triggerScenarios":"Thrown at pkg/fsutils/linecache.go:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the linter or caller supplying an invalid line number","Validate line numbers before requesting lines","Report the offending linter if it emits line 0 or negative positions"],"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"}