{"record":{"id":"548aa877f32fb54a","repo":"ipfs/kubo","slug":"invalid-encoding-s-s","errorCode":null,"errorMessage":"invalid encoding: %s - %s","messagePattern":"invalid encoding: (.+?) - (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/dag/get.go","lineNumber":67,"sourceCode":"\tuniversal, ok := obj.(ipldlegacy.UniversalNode)\n\tif !ok {\n\t\treturn fmt.Errorf(\"%T is not a valid IPLD node\", obj)\n\t}\n\n\tfinalNode := universal.(ipld.Node)\n\n\tif len(remainder) > 0 {\n\t\tremainderPath := ipld.ParsePath(path.SegmentsToString(remainder...))\n\n\t\tfinalNode, err = traversal.Get(finalNode, remainderPath)\n\t\tif err != nil {\n\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}()","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/dag/get.go#L49-L85","documentation":"`ipfs dag get` re-encodes the fetched IPLD node using the multicodec named by the node's CID (or --output-codec). Before encoding, kubo looks up a registered encoder for that codec with multicodec.LookupEncoder. If no encoder is registered for the codec, the command fails with this wrapped error showing the codec name/number and the underlying lookup error.","triggerScenarios":"Running `ipfs dag get <cid>` or `ipfs dag get --output-codec=<codec> <cid>` where the requested codec has no registered multicodec encoder in the process (e.g. an exotic or unregistered codec number, or a codec compiled out).","commonSituations":"Requesting a CID whose codec is not a standard serialization (e.g. raw dag-pb-less CIDs from other ecosystems); using --output-codec with a typo'd or unsupported value such as a codec only known in newer ipld-prime/codec registrations than the installed kubo version; plugins providing codecs not loaded.","solutions":["Use a supported codec: dag-cbor, dag-json, dag-pb, or raw","Check the CID's codec with `ipfs dag stat` or `ipfs cid format -f %z` and fetch with a codec kubo can encode","Upgrade kubo if the codec was added in a newer multicodec table","Register the codec via a kubo plugin if it is a custom codec"],"exampleFix":"// before\nipfs dag get --output-codec=cty bafy...\n// error: invalid encoding: cty - no encoder found\n// after\nipfs dag get --output-codec=dag-json bafy...","handlingStrategy":"validation","validationCode":"// Check the CID's codec before calling dag get\nparts := strings.SplitN(cidStr, \"/\", 2)\nc, err := cid.Decode(parts[0])\nif err != nil { return err }\nswitch c.Type() {\ncase cid.DagProtobuf, cid.DagCBOR, cid.DagJSON, cid.Raw:\n    // supported\ndefault:\n    return fmt.Errorf(\"codec %d not encodable by kubo; use --output-codec=dag-json\", c.Type())\n}","typeGuard":null,"tryCatchPattern":"// CLI: detect and fall back\nif out, err := sh.Command(\"ipfs\", \"dag\", \"get\", cid).Output(); err != nil {\n    if strings.Contains(string(err.(*exec.ExitError).Stderr), \"invalid encoding\") {\n        return sh.Command(\"ipfs\", \"dag\", \"get\", \"--output-codec=dag-json\", cid).Output()\n    }\n    return err\n}","preventionTips":["Prefer standard codecs (dag-cbor, dag-pb, dag-json, raw)","Inspect CID codec with `ipfs cid format -f %z` before dag get","Keep kubo/multicodec tables current"],"tags":["cli","ipld","multicodec","encoding"],"backgroundTag":"unsupported-ipld-codec","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"}