{"record":{"id":"526d7e5d9afeae2b","repo":"ipfs/kubo","slug":"internal-error-encoding-node","errorCode":null,"errorMessage":"internal error encoding node","messagePattern":"internal error encoding node","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/dag/get.go","lineNumber":79,"sourceCode":"\t\t\treturn err\n\t\t}\n\t}\n\n\tencoder, err := multicodec.LookupEncoder(uint64(codec))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid encoding: %s - %s\", codec, err)\n\t}\n\n\tr, w := io.Pipe()\n\tgo func() {\n\t\tdefer w.Close()\n\t\t// Encoding runs the codec named by the node's CID, so it runs\n\t\t// third-party code. This goroutine is detached from the request, and a\n\t\t// panic on it would end the daemon rather than the command.\n\t\tdefer func() {\n\t\t\tif rec := recover(); rec != nil {\n\t\t\t\tlog.Errorf(\"recovered from panic encoding %s as %s: %v\\n%s\", p, codec, rec, debug.Stack())\n\t\t\t\t_ = w.CloseWithError(errors.New(\"internal error encoding node\"))\n\t\t\t}\n\t\t}()\n\t\tif err := encoder(finalNode, w); err != nil {\n\t\t\t_ = w.CloseWithError(err)\n\t\t}\n\t}()\n\n\treturn res.Emit(r)\n}\n","sourceCodeStart":61,"sourceCodeEnd":89,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/dag/get.go#L61-L89","documentation":"The actual encoding of the DAG node runs in a detached goroutine writing into an io.Pipe, because codecs are third-party code and a panic there would kill the whole daemon. If the encoder panics, the goroutine recovers it, logs a stack trace, and closes the pipe with the error \"internal error encoding node\", which surfaces to the client as the command's failure.","triggerScenarios":"`ipfs dag get` where a registered multicodec encoder panics on the node being serialized (buggy codec implementation, node shape the codec cannot handle).","commonSituations":"Corrupt or unusual DAG node structures fed to dag-pb/dag-cbor encoders; bugs in custom codec plugins; rare upstream ipld codec regressions.","solutions":["Check the daemon log for the recovered-panic message with stack trace to identify the codec","Retry with --output-codec=dag-json or another codec to work around the faulty encoder","Report the panic (with the stack trace) to the codec/kubo project","Upgrade kubo / the codec library to a version with the panic fixed"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// CLI: retry with a different output codec on internal encoding error\nout, err := exec.Command(\"ipfs\", \"dag\", \"get\", cid).Output()\nif err != nil && strings.Contains(errText(err), \"internal error encoding node\") {\n    out, err = exec.Command(\"ipfs\", \"dag\", \"get\", \"--output-codec=dag-json\", cid).Output()\n}","preventionTips":["Monitor daemon logs for 'recovered from panic encoding' to find the faulty codec","Avoid exotic codecs in production pipelines","Report codec panics upstream with the logged stack trace"],"tags":["cli","ipld","panic","encoding"],"backgroundTag":"codec-panic-recovered","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"}