{"record":{"id":"e2b5cbc6e1847230","repo":"ipfs/kubo","slug":"peer-id-invalid-s","errorCode":null,"errorMessage":"peer ID invalid: %s","messagePattern":"peer ID invalid: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/node/groups.go","lineNumber":281,"sourceCode":"\t\tfinalBstore,\n\t)\n}\n\n// Identity groups units providing cryptographic identity\nfunc Identity(cfg *config.Config) fx.Option {\n\t// PeerID\n\n\tcid := cfg.Identity.PeerID\n\tif cid == \"\" {\n\t\treturn fx.Error(errors.New(\"identity was not set in config (was 'ipfs init' run?)\"))\n\t}\n\tif len(cid) == 0 {\n\t\treturn fx.Error(errors.New(\"no peer ID in config! (was 'ipfs init' run?)\"))\n\t}\n\n\tid, err := peer.Decode(cid)\n\tif err != nil {\n\t\treturn fx.Error(fmt.Errorf(\"peer ID invalid: %s\", err))\n\t}\n\n\t// Private Key\n\n\tif cfg.Identity.PrivKey == \"\" {\n\t\treturn fx.Options( // No PK (usually in tests)\n\t\t\tfx.Provide(PeerID(id)),\n\t\t\tfx.Provide(libp2p.Peerstore),\n\t\t)\n\t}\n\n\tsk, err := cfg.Identity.DecodePrivateKey(\"passphrase todo!\")\n\tif err != nil {\n\t\treturn fx.Error(err)\n\t}\n\n\treturn fx.Options( // Full identity\n\t\tfx.Provide(PeerID(id)),","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/node/groups.go#L263-L299","documentation":"The PeerID string in Identity.PeerID exists but fails peer.Decode — it is not a valid multihash/base58 peer ID. Node construction aborts because every libp2p component depends on a decodable identity.","triggerScenarios":"`peer.Decode(cfg.Identity.PeerID)` returns an error — malformed base58, wrong length, truncated CID, or non-peer-ID content pasted into PeerID.","commonSituations":"Hand-editing config.json and corrupting the PeerID; copying an ID with whitespace or line-wrap; pasting a libp2p key or CID instead of a peer ID; partial restore of a config backup.","solutions":["Restore the original Identity.PeerID (and matching PrivKey) from backup","Re-init the repo (`ipfs init`) if the identity is unrecoverable — note this generates a new peer identity","Trim whitespace/newlines around the PeerID value and verify it decodes (e.g. `ipfs id <peerID>` validates a peer ID)"],"exampleFix":"// before (config.json)\n\"Identity\": { \"PeerID\": \"12D3KooW...\\n  \" }\n// after\n\"Identity\": { \"PeerID\": \"12D3KooWAbcdefghijklmnopqrstuvwxyzExample\" }","handlingStrategy":"validation","validationCode":"if _, err := peer.Decode(cfg.Identity.PeerID); err != nil {\n\treturn fmt.Errorf(\"Identity.PeerID is not a valid peer ID: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if _, err := peer.Decode(peerIDStr); err != nil {\n\t// restore from backup or re-init\n\treturn fmt.Errorf(\"invalid peer ID in config: %w\", err)\n}","preventionTips":["Never hand-edit the PeerID value; copy the whole string exactly","Trim whitespace when copying peer IDs between systems","Keep PeerID and PrivKey paired when restoring backups"],"tags":["config","identity","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"}