{"record":{"id":"8544e963c305249a","repo":"ipfs/kubo","slug":"cannot-specify-negative-offset-8544e9","errorCode":null,"errorMessage":"cannot specify negative offset","messagePattern":"cannot specify negative offset","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":863,"sourceCode":"\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s: %w\", path, err)\n\t\t}\n\n\t\tfi, ok := fsn.(*mfs.File)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s was not a file\", path)\n\t\t}\n\n\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)","sourceCodeStart":845,"sourceCodeEnd":881,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L845-L881","documentation":"Fired by `ipfs files read` when the --offset option is explicitly negative. The option is read via a type assertion (a missing option defaults to 0), so this only triggers when the user supplied an offset below zero, which is meaningless for a seek-based read and is rejected before the file is read.","triggerScenarios":"Thrown at core/commands/files.go:863 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a zero or positive --offset","Omit -o to read from the beginning of the 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"}