ipfs/kubo · error

panic(err)

Error message

panic(err)

What it means

Fired inside KeyEncoder.FormatID when peer.ToCid(id).StringOfBase fails to re-encode an already-valid peer ID into the multibase selected via --ipns-base. The peer ID itself is valid, so failure means the requested base encoding cannot represent the CID form of the ID; unlike KeyEncoderFromString this path has no error return, so the command panics and the CLI aborts instead of printing the ID.

Source

Thrown at core/commands/keyencode/keyencode.go:35

func KeyEncoderFromString(formatLabel string) (KeyEncoder, error) {
	switch formatLabel {
	case "b58mh", "v0":
		return KeyEncoder{}, nil
	default:
		if enc, err := mbase.EncoderByName(formatLabel); err != nil {
			return KeyEncoder{}, err
		} else {
			return KeyEncoder{&enc}, nil
		}
	}
}

func (enc KeyEncoder) FormatID(id peer.ID) string {
	if enc.baseEnc == nil {
		return id.String()
	}
	if s, err := peer.ToCid(id).StringOfBase(enc.baseEnc.Encoding()); err != nil {
		panic(err)
	} else {
		return s
	}
}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Use a supported --ipns-base value such as b58mh, v0, base36, or base32
  2. Verify the peer ID is well-formed before formatting if it came from user input
  3. If it recurs on a valid ID with a standard base, report it as a bug since StringOfBase should not fail for valid IDs
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at core/commands/keyencode/keyencode.go:35 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/0f9fbf6595d36212. Report an issue: GitHub.