{"record":{"id":"ed8b96fa8e668dca","repo":"ipfs/kubo","slug":"invalid-peer-id","errorCode":null,"errorMessage":"invalid peer id","messagePattern":"invalid peer id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/id.go","lineNumber":85,"sourceCode":"\t\tcmds.StringOption(idFormatOptionName, \"Encoding used for peer IDs: Can either be a multibase encoded CID or a base58btc encoded multihash. Takes {b58mh|base36|k|base32|b...}.\").WithDefault(\"b58mh\"),\n\t},\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tkeyEnc, err := ke.KeyEncoderFromString(req.Options[idFormatOptionName].(string))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tn, err := cmdenv.GetNode(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tvar id peer.ID\n\t\tif len(req.Arguments) > 0 {\n\t\t\tvar err error\n\t\t\tid, err = peer.Decode(req.Arguments[0])\n\t\t\tif err != nil {\n\t\t\t\treturn errors.New(\"invalid peer id\")\n\t\t\t}\n\t\t} else {\n\t\t\tid = n.Identity\n\t\t}\n\n\t\tif id == n.Identity {\n\t\t\toutput, err := printSelf(keyEnc, n)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn cmds.EmitOnce(res, output)\n\t\t}\n\n\t\toffline, _ := req.Options[OfflineOption].(bool)\n\t\tif !offline && !n.IsOnline {\n\t\t\treturn errors.New(offlineIDErrorMessage)\n\t\t}\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/id.go#L67-L103","documentation":"`ipfs id <peerid>` decodes its first positional argument with `peer.Decode`. If the string is not a valid libp2p peer ID (correct multibase/multihash encoding), the command returns 'invalid peer id'. This is a pure input-parsing failure before any network activity.","triggerScenarios":"Passing a truncated or typo'd peer ID; passing a base58 peer ID while it was produced in base36/base32 (CIDv1-style peer IDs, common with new IPNS keys); passing something that is not a peer ID at all (e.g. a CID of content, a multiaddr, or a file path).","commonSituations":"Copy-paste truncation of long peer IDs; new-style RSA/Ed25519 peer IDs rendered in base36 that need `--peerid-base` set; confusing an IPNS key/CID with a peer ID; empty or whitespace argument from an unexpanded shell variable.","solutions":["Verify the peer ID string is complete and correctly copied (no truncation, no whitespace).","If the ID is CIDv1-encoded (starts with 1 or 2, e.g. base36 `k...` or base32 `b...`), pass `--peerid-base=base36` or `base32`.","If you have a multiaddr, extract only the `/p2p/<peerid>` component (or use `/p2p/` part) and pass just the ID.","Cross-check the peer ID with `ipfs key list -l` or `ipfs id` of a node you control."],"exampleFix":"// before\nipfs id k2k4r8k9...            // fails: CIDv1 peer id not decodable as default base\n// after\nipfs id --peerid-base=base36 k2k4r8k9...","handlingStrategy":"validation","validationCode":"import \"github.com/libp2p/go-libp2p/core/peer\"\n\nif _, err := peer.Decode(peerIDArg); err != nil {\n    return fmt.Errorf(\"not a valid peer id %q: %w\", peerIDArg, err)\n}","typeGuard":null,"tryCatchPattern":"if _, err := sh.Request(\"id\", peerID).Send(ctx); err != nil {\n    if strings.Contains(err.Error(), \"invalid peer id\") {\n        // try alternate peer-id bases\n        _, err = sh.Request(\"id\", peerID).Option(\"peerid-base\", \"base36\").Send(ctx)\n    }\n}","preventionTips":["Copy peer IDs in full; they are long multihashes and partial copies fail to decode","Match --peerid-base to the encoding you have (base58 legacy, base36/base32 for CIDv1-style)","Do not pass CIDs, IPNS keys, or multiaddrs where a peer ID is expected; strip multiaddrs down to the /p2p/<id> component"],"tags":["cli","libp2p","peer-id","validation"],"backgroundTag":"invalid-peer-id","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"}