{"record":{"id":"32189ed48e895ed1","repo":"ipfs/kubo","slug":"attempted-to-print-nil-peer","errorCode":null,"errorMessage":"attempted to print nil peer","messagePattern":"attempted to print nil peer","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/id.go","lineNumber":151,"sourceCode":"\t\t\t\toutput = strings.Replace(output, \"\\\\t\", \"\\t\", -1)\n\t\t\t\tfmt.Fprint(w, output)\n\t\t\t} else {\n\t\t\t\tmarshaled, err := json.MarshalIndent(out, \"\", \"\\t\")\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tmarshaled = append(marshaled, byte('\\n'))\n\t\t\t\tfmt.Fprintln(w, string(marshaled))\n\t\t\t}\n\t\t\treturn nil\n\t\t}),\n\t},\n\tType: IdOutput{},\n}\n\nfunc printPeer(keyEnc ke.KeyEncoder, ps pstore.Peerstore, p peer.ID) (any, error) {\n\tif p == \"\" {\n\t\treturn nil, errors.New(\"attempted to print nil peer\")\n\t}\n\n\tinfo := new(IdOutput)\n\tinfo.ID = keyEnc.FormatID(p)\n\n\tif pk := ps.PubKey(p); pk != nil {\n\t\tpkb, err := ic.MarshalPublicKey(pk)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tinfo.PublicKey = base64.StdEncoding.EncodeToString(pkb)\n\t}\n\n\taddrInfo := ps.PeerInfo(p)\n\taddrs, err := peer.AddrInfoToP2pAddrs(&addrInfo)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/id.go#L133-L169","documentation":"Guard in printPeer, the output builder for `ipfs id`: the resolved peer.ID is the empty string, meaning identity lookup produced no peer rather than a real node identity. This is an internal invariant check — normally unreachable from the CLI since the command reads the node's own identity — and the peerstore is not queried further.","triggerScenarios":"Thrown at core/commands/id.go:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check daemon startup logs for identity/key loading failures; an empty peer ID usually means the node's private key could not be read from IPFS_PATH.","Verify the repo's identity key exists and is valid (re-init the repo if it is missing/corrupt), then restart the daemon."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}