micro/go-micro · error
unsupported Content-Type: %s
Error message
unsupported Content-Type: %s
What it means
Error "unsupported Content-Type: %s" thrown in micro/go-micro.
Source
Thrown at client/grpc/grpc.go:362
return DefaultMaxSendMsgSize
}
return v.(int)
}
func (g *grpcClient) newGRPCCodec(contentType string) (encoding.Codec, error) {
codecs := make(map[string]encoding.Codec)
if g.opts.Context != nil {
if v := g.opts.Context.Value(codecsKey{}); v != nil {
codecs = v.(map[string]encoding.Codec)
}
}
if c, ok := codecs[contentType]; ok {
return wrapCodec{c}, nil
}
if c, ok := defaultGRPCCodecs[contentType]; ok {
return wrapCodec{c}, nil
}
return nil, fmt.Errorf("unsupported Content-Type: %s", contentType)
}
func (g *grpcClient) Init(opts ...client.Option) error {
size := g.opts.PoolSize
ttl := g.opts.PoolTTL
for _, o := range opts {
o(&g.opts)
}
// update pool configuration if the options changed
if size != g.opts.PoolSize || ttl != g.opts.PoolTTL {
g.pool.Lock()
g.pool.size = g.opts.PoolSize
g.pool.ttl = int64(g.opts.PoolTTL.Seconds())
g.pool.Unlock()
}
View on GitHub (pinned to 24529f1404)
Solutions
- Use a supported Content-Type: application/grpc+proto, application/grpc+json, or application/grpc+bytes
- Register a custom codec via codec registration before making calls if you need a custom format
- Fix typos in the configured Content-Type option
- Omit the Content-Type option to use the default application/grpc+proto
Example fix
// before
client.ContentType("application/grpc+msgpack")
// after
client.ContentType("application/grpc+json") Defensive patterns
Strategy: validation
Validate before calling
var defaultGRPCContentTypes = []string{
"application/grpc", "application/grpc+proto", "application/grpc+json", "application/grpc+bytes",
}
func contentTypeSupported(ct string) bool {
return slices.Contains(defaultGRPCContentTypes, ct)
} Try / catch
err := client.Call(ctx, req, resp)
if err != nil && strings.Contains(err.Error(), "unsupported Content-Type") {
// fix client.ContentType option at startup
} Prevention
- Centralize Content-Type strings as constants, never inline literals
- Validate the ContentType option at service startup
- Consult the gRPC codec map before adding a custom type
- Register custom codecs before any call is made
When it happens
Trigger: Setting client.ContentType or service Content-Type to something like application/grpc+msgpack, text/plain, or a typo such as application/grpc+protobuff while using the gRPC client.
Common situations: Copy-pasted Content-Type strings with typos; switching clients from mucp (json) to grpc without updating the content type; using a codec name supported elsewhere but not compiled into the gRPC codec map.
Related errors
- unsupported Content-Type
- unsupported Content-Type: %s
- unknown request path
- failed to marshal: %v is not type of *bytes.Frame or proto.M
- failed to unmarshal: %v is not type of proto.Message
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/97f49f2a730f2fea.
Report an issue: GitHub.