{"record":{"id":"65c2d6ba1193a56e","repo":"micro/go-micro","slug":"unsupported-content-type-s-65c2d6","errorCode":null,"errorMessage":"unsupported Content-Type: %s","messagePattern":"unsupported Content-Type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/rpc_client.go","lineNumber":76,"sourceCode":"\n\t// wrap in reverse\n\tfor i := len(opts.Wrappers); i > 0; i-- {\n\t\tc = opts.Wrappers[i-1](c)\n\t}\n\n\treturn c\n}\n\nfunc (r *rpcClient) newCodec(contentType string) (codec.NewCodec, error) {\n\tif c, ok := r.opts.Codecs[contentType]; ok {\n\t\treturn c, nil\n\t}\n\n\tif cf, ok := DefaultCodecs[contentType]; ok {\n\t\treturn cf, nil\n\t}\n\n\treturn nil, fmt.Errorf(\"unsupported Content-Type: %s\", contentType)\n}\n\nfunc (r *rpcClient) call(\n\tctx context.Context,\n\tnode *registry.Node,\n\treq Request,\n\tresp interface{},\n\topts CallOptions,\n) error {\n\t// In-process fast-path: if the callee runs in this process and both bodies\n\t// are raw frames, dispatch directly and skip the network entirely.\n\tif handled, err := r.localCall(ctx, req, resp); handled {\n\t\treturn err\n\t}\n\n\taddress := node.Address\n\tlogger := r.Options().Logger\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/client/rpc_client.go#L58-L94","documentation":"The generic rpcClient's newCodec looked up the request Content-Type in DefaultCodecs and found no match, so it cannot encode the request. This happens for the default (mucp/rpc) client, independent of the gRPC-specific check, and fails the call/stream/Publish before any network I/O.","triggerScenarios":"Configuring client.ContentType (or a service's advertised content type) to a value absent from DefaultCodecs — e.g. \"application/xml\", \"text/plain\", or a misspelled \"applcation/json\" — then calling call, Stream, or Publish.","commonSituations":"Typos in content-type strings; copying options between transports where the codec sets differ; middleware or plugins overriding ContentType with an unsupported value.","solutions":["Use a supported Content-Type such as application/json, application/protobuf, or application/octet-stream (see DefaultCodecs)","Fix the typo in the ContentType client option","Register a custom codec in DefaultCodecs at startup if the format is genuinely needed","Log/inspect the configured ContentType at boot to catch drift"],"exampleFix":"// before\nclient.ContentType(\"application/xml\")\n// after\nclient.ContentType(\"application/json\")","handlingStrategy":"validation","validationCode":"var supported = []string{\"application/json\", \"application/protobuf\", \"application/octet-stream\"}\nif !slices.Contains(supported, clientOptsContentType) {\n    return fmt.Errorf(\"content type %q not in DefaultCodecs\", clientOptsContentType)\n}","typeGuard":null,"tryCatchPattern":"err := client.Publish(ctx, topic, msg)\nif err != nil && strings.Contains(err.Error(), \"unsupported Content-Type\") {\n    // correct client.ContentType to a DefaultCodecs entry\n}","preventionTips":["Define content types as named constants","Check DefaultCodecs when choosing a ContentType value","Cover client setup in startup smoke tests","Avoid ad-hoc overrides in middleware"],"tags":["rpc","codec","content-type","configuration"],"backgroundTag":"unsupported-content-type","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}