{"record":{"id":"8a92afa524a41950","repo":"ipfs/kubo","slug":"cannot-have-negative-write-offset","errorCode":null,"errorMessage":"cannot have negative write offset","messagePattern":"cannot have negative write offset","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1093,"sourceCode":"\t\trawLeaves, rawLeavesDef := req.Options[filesRawLeavesOptionName].(bool)\n\n\t\tif err := updateNoFlushCounter(nd, flush); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif !rawLeavesDef && cfg.Import.UnixFSRawLeaves != config.Default {\n\t\t\trawLeavesDef = true\n\t\t\trawLeaves = cfg.Import.UnixFSRawLeaves.WithDefault(config.DefaultUnixFSRawLeaves)\n\t\t}\n\n\t\tprefix, err := getPrefix(req, &cfg.Import)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\toffset, _ := req.Options[filesOffsetOptionName].(int64)\n\t\tif offset < 0 {\n\t\t\treturn fmt.Errorf(\"cannot have negative write offset\")\n\t\t}\n\n\t\tif mkParents {\n\t\t\tmaxDirLinks := int(cfg.Import.UnixFSDirectoryMaxLinks.WithDefault(config.DefaultUnixFSDirectoryMaxLinks))\n\t\t\tsizeEstimationMode := cfg.Import.HAMTSizeEstimationMode()\n\t\t\terr := ensureContainingDirectoryExists(nd.FilesRoot, path,\n\t\t\t\tmfs.WithCidBuilder(prefix),\n\t\t\t\tmfs.WithMaxLinks(maxDirLinks),\n\t\t\t\tmfs.WithSizeEstimationMode(sizeEstimationMode),\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tfi, err := getFileHandle(nd.FilesRoot, path, create, prefix)\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":1075,"sourceCodeEnd":1111,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1075-L1111","documentation":"Guard in the `ipfs files write` handler: the --offset option was parsed as a negative int64 and is rejected before the destination file is opened or written. Pure input validation; a negative seek offset is not supported for MFS writes.","triggerScenarios":"Thrown at core/commands/files.go:1093 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a non-negative --offset value.","If appending was intended, omit --offset or compute the file size with `ipfs files stat` instead of passing a negative value."],"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"}