{"record":{"id":"0f9fbf6595d36212","repo":"ipfs/kubo","slug":"panic-err","errorCode":null,"errorMessage":"panic(err)","messagePattern":"panic\\(err\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/keyencode/keyencode.go","lineNumber":35,"sourceCode":"func KeyEncoderFromString(formatLabel string) (KeyEncoder, error) {\n\tswitch formatLabel {\n\tcase \"b58mh\", \"v0\":\n\t\treturn KeyEncoder{}, nil\n\tdefault:\n\t\tif enc, err := mbase.EncoderByName(formatLabel); err != nil {\n\t\t\treturn KeyEncoder{}, err\n\t\t} else {\n\t\t\treturn KeyEncoder{&enc}, nil\n\t\t}\n\t}\n}\n\nfunc (enc KeyEncoder) FormatID(id peer.ID) string {\n\tif enc.baseEnc == nil {\n\t\treturn id.String()\n\t}\n\tif s, err := peer.ToCid(id).StringOfBase(enc.baseEnc.Encoding()); err != nil {\n\t\tpanic(err)\n\t} else {\n\t\treturn s\n\t}\n}\n","sourceCodeStart":17,"sourceCodeEnd":40,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/keyencode/keyencode.go#L17-L40","documentation":"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.","triggerScenarios":"Thrown at core/commands/keyencode/keyencode.go:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a supported --ipns-base value such as b58mh, v0, base36, or base32","Verify the peer ID is well-formed before formatting if it came from user input","If it recurs on a valid ID with a standard base, report it as a bug since StringOfBase should not fail for valid IDs"],"exampleFix":null,"handlingStrategy":"try-catch","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"}