{"record":{"id":"1c15e59de10e809e","repo":"ipfs/kubo","slug":"failed-to-read-record-w","errorCode":null,"errorMessage":"failed to read record: %w","messagePattern":"failed to read record: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/name/name.go","lineNumber":486,"sourceCode":"\t\t}\n\t\t// Extract the name part after /ipns/\n\t\tnamePart := strings.TrimPrefix(nameArg, \"/ipns/\")\n\t\tname, err := ipns.NameFromString(namePart)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid IPNS name: %w\", err)\n\t\t}\n\n\t\t// Read raw record bytes from file/stdin\n\t\tfile, err := cmdenv.GetFileArg(req.Files.Entries())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer file.Close()\n\n\t\t// Read record data (limit to 1 MiB for memory safety)\n\t\tdata, err := io.ReadAll(io.LimitReader(file, 1<<20))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to read record: %w\", err)\n\t\t}\n\t\tif len(data) == 0 {\n\t\t\treturn errors.New(\"record is empty\")\n\t\t}\n\n\t\t// Validate unless --force\n\t\tif !force {\n\t\t\t// Check size limit per IPNS spec\n\t\t\tif len(data) > maxIPNSRecordSize {\n\t\t\t\treturn fmt.Errorf(\"record exceeds maximum size of %d bytes, use --force to skip size check\", maxIPNSRecordSize)\n\t\t\t}\n\t\t\trec, err := ipns.UnmarshalRecord(data)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid IPNS record: %w\", err)\n\t\t\t}\n\n\t\t\t// Validate signature against provided name\n\t\t\terr = ipns.ValidateWithName(rec, name)","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/name/name.go#L468-L504","documentation":"Returned when reading the raw IPNS record bytes (from the file/stdin argument, capped at 1 MiB via io.LimitReader) fails. The wrapped error is the underlying read I/O failure. (An empty record is rejected separately right after.)","triggerScenarios":"`ipfs ipns put <name> <file>` where the record file cannot be read mid-stream — I/O error on the device, pipe producer failure while reading stdin.","commonSituations":"Piping record data from a process that dies mid-write, reading from an unreadable/special file, or storage errors on the record file.","solutions":["Verify the record file is a readable regular file and retry","If piping, ensure the producing command (e.g. ipns sign/presign tool) exits successfully","Regenerate the record file if it is on flaky storage"],"exampleFix":"// before\nsome-producer | ipfs ipns put --allow-offline --key=self\n// error: failed to read record: read |0: file already closed\n// after\nsome-producer > record.bin && ipfs ipns put --allow-offline --key=self record.bin","handlingStrategy":"try-catch","validationCode":"fi, err := os.Stat(recordFile)\nif err != nil || !fi.Mode().IsRegular() || fi.Size() == 0 || fi.Size() > 1<<20 {\n    return errors.New(\"record file must be a non-empty regular file under 1 MiB\")\n}","typeGuard":null,"tryCatchPattern":"data, err := io.ReadAll(io.LimitReader(f, 1<<20))\nif err != nil {\n    return fmt.Errorf(\"failed to read record: %w\", err)\n}","preventionTips":["Write records to a temp file before publishing instead of long pipe chains","Check producer exit status before consuming its output"],"tags":["ipns","io","record"],"backgroundTag":"file-read-failed","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"}