ipfs/kubo · error
attempted to print nil peer
Error message
attempted to print nil peer
What it means
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.
Source
Thrown at core/commands/id.go:151
output = strings.Replace(output, "\\t", "\t", -1)
fmt.Fprint(w, output)
} else {
marshaled, err := json.MarshalIndent(out, "", "\t")
if err != nil {
return err
}
marshaled = append(marshaled, byte('\n'))
fmt.Fprintln(w, string(marshaled))
}
return nil
}),
},
Type: IdOutput{},
}
func printPeer(keyEnc ke.KeyEncoder, ps pstore.Peerstore, p peer.ID) (any, error) {
if p == "" {
return nil, errors.New("attempted to print nil peer")
}
info := new(IdOutput)
info.ID = keyEnc.FormatID(p)
if pk := ps.PubKey(p); pk != nil {
pkb, err := ic.MarshalPublicKey(pk)
if err != nil {
return nil, err
}
info.PublicKey = base64.StdEncoding.EncodeToString(pkb)
}
addrInfo := ps.PeerInfo(p)
addrs, err := peer.AddrInfoToP2pAddrs(&addrInfo)
if err != nil {
return nil, err
}View on GitHub (pinned to 329838acdf)
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.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at core/commands/id.go:151 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/32189ed48e895ed1.
Report an issue: GitHub.