{"record":{"id":"341eabed4daa2be4","repo":"go-kratos/kratos","slug":"cannot-register-codec-with-empty-string-result-for","errorCode":null,"errorMessage":"cannot register Codec with empty string result for Name()","messagePattern":"cannot register Codec with empty string result for Name\\(\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"encoding/encoding.go","lineNumber":30,"sourceCode":"\tMarshal(v any) ([]byte, error)\n\t// Unmarshal parses the wire format into v.\n\tUnmarshal(data []byte, v any) error\n\t// Name returns the name of the Codec implementation. The returned string\n\t// will be used as part of content type in transmission. The result must be\n\t// static; the result cannot change between calls.\n\tName() string\n}\n\nvar registeredCodecs = make(map[string]Codec)\n\n// RegisterCodec registers the provided Codec for use with all Transport clients and\n// servers.\nfunc RegisterCodec(codec Codec) {\n\tif codec == nil {\n\t\tpanic(\"cannot register a nil Codec\")\n\t}\n\tif codec.Name() == \"\" {\n\t\tpanic(\"cannot register Codec with empty string result for Name()\")\n\t}\n\tcontentSubtype := strings.ToLower(codec.Name())\n\tregisteredCodecs[contentSubtype] = codec\n}\n\n// GetCodec gets a registered Codec by content-subtype, or nil if no Codec is\n// registered for the content-subtype.\n//\n// The content-subtype is expected to be lowercase.\nfunc GetCodec(contentSubtype string) Codec {\n\treturn registeredCodecs[contentSubtype]\n}\n","sourceCodeStart":12,"sourceCodeEnd":43,"githubUrl":"https://github.com/go-kratos/kratos/blob/668db92c2c001e9552594ba5a8aede8456af6d7e/encoding/encoding.go#L12-L43","documentation":"Error \"cannot register Codec with empty string result for Name()\" thrown in go-kratos/kratos.","triggerScenarios":"Thrown at encoding/encoding.go:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"668db92c2c001e9552594ba5a8aede8456af6d7e","analyzedAt":"2026-08-16T02:07:20.704Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}