{"record":{"id":"b12867c6e6ad4e37","repo":"ipfs/kubo","slug":"offset-was-past-end-of-file-d-d","errorCode":null,"errorMessage":"offset was past end of file (%d > %d)","messagePattern":"offset was past end of file \\((.+?) > (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":872,"sourceCode":"\t\trfd, err := fi.Open(req.Context, mfs.Flags{Read: true})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdefer rfd.Close()\n\n\t\toffset, _ := req.Options[offsetOptionName].(int64)\n\t\tif offset < 0 {\n\t\t\treturn fmt.Errorf(\"cannot specify negative offset\")\n\t\t}\n\n\t\tfilen, err := rfd.Size()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif int64(offset) > filen {\n\t\t\treturn fmt.Errorf(\"offset was past end of file (%d > %d)\", offset, filen)\n\t\t}\n\n\t\t_, err = rfd.Seek(int64(offset), io.SeekStart)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tvar r io.Reader = &contextReaderWrapper{R: rfd, ctx: req.Context}\n\t\tcount, found := req.Options[filesCountOptionName].(int64)\n\t\tif found {\n\t\t\tif count < 0 {\n\t\t\t\treturn fmt.Errorf(\"cannot specify negative 'count'\")\n\t\t\t}\n\t\t\tr = io.LimitReader(r, int64(count))\n\t\t}\n\t\treturn res.Emit(r)\n\t},\n}","sourceCodeStart":854,"sourceCodeEnd":890,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L854-L890","documentation":"'ipfs files read': the requested --offset exceeds the file's size (%d > %d), so the read would start past EOF and return nothing meaningful; the command rejects it up front after querying the MFS file's size.","triggerScenarios":"Thrown at core/commands/files.go:872 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an offset smaller than the file size (check with 'ipfs files stat <path>')","Combine with --count to bound the read length","Drop the offset to read the whole file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}