go
protobuf_error
ai_generated
true
cannot use type *v1.FooRequest as type *v2.FooRequest in argument to RegisterFooServer
ID: go/protobuf-mismatch
85%Fix Rate
87%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
Root Cause
Generated protobuf Go code is out of sync with the .proto definitions or incompatible protobuf library versions are mixed. Commonly happens when client and server use different generated code versions.
genericWorkarounds
-
92% success Regenerate all protobuf Go code from the same .proto files
protoc --go_out=. --go-grpc_out=. proto/*.proto Ensure all services use the same generated package.
-
88% success Pin protobuf library versions consistently across all modules
go get google.golang.org/protobuf@latest go get google.golang.org/grpc@latest go mod tidy
Dead Ends
Common approaches that don't work:
-
Manually edit generated .pb.go files to fix type mismatches
95% fail
Generated files are overwritten on next protoc run — manual edits are lost and the underlying .proto mismatch remains
-
Mix google.golang.org/protobuf and github.com/golang/protobuf v1 APIs
80% fail
The two protobuf Go API versions generate incompatible types — mixing them causes type assertion failures
Error Chain
Leads to:
Preceded by:
Frequently confused with: