go
type_error
ai_generated
true
rpc error: code = InvalidArgument desc = expected string, got number for field age
ID: go/grpc-invalid-argument-field-type
80%Fix Rate
85%Confidence
0Evidence
2025-04-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.56.x | active | — | — | — |
| 1.57.x | active | — | — | — |
Root Cause
The protobuf message field type mismatch; e.g., sending an integer where a string is expected.
generic中文
protobuf 消息字段类型不匹配;例如,在期望字符串的地方发送了整数。
Workarounds
-
95% success
string age = 1; protoc --go_out=. *.proto
-
90% success
req := &pb.Person{Age: strconv.Itoa(30)} -
85% success
if _, ok := req.Age.(string); !ok { return status.Error(codes.InvalidArgument, "age must be string") }
Dead Ends
Common approaches that don't work:
-
Continuing to send incorrect type.
100% fail
Same error persists.
-
Using type assertion without changing proto.
80% fail
Proto definition determines wire format.
-
Blaming server for type checking.
50% fail
Client must follow proto definition.