grpc-gateway
grpc-gateway copied to clipboard
protoc-gen fails silently
🐛 Bug Report
protoc-gen fails silently if the rpc request object is missing some fields
To Reproduce
Create a rpc method with path indicating that it needs N parameters but the request object is missing some
Following example needs clinic_id ,patient_id, order_id but has only clinic_id. It silently fails }
rpc GetOrder(GetOrderRequest) returns (GetOrderResponse) {
option (google.api.http) = {get: "/v1/clinics/{clinic_id}/patients/{patient_id}/orders/{order_id}"};
option (openapi.v3.operation) = {
security: []
responses: {
response_or_reference: [
{
name: "400"
value: {
reference: {_ref: "#/components/responses/BadRequest"}
}
}
]
}
};
}
.
.
.
message GetOrderRequest {
string clinic_id = 1;
}
Expected behavior
Fail with error
Actual Behavior
Fail to create the .pb.pw.go file
Your Environment
› go version
go version go1.24.3 darwin/arm64
› uname -a
Darwin local.local 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:29 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6030 arm64
I tried this out locally and I get an error:
Failure: plugin protoc-gen-grpc-gateway: no field "patient_id" found in GetOrderRequest
Could you share an example repo showing the problem?
@sarathsp06 your http path has 3 parameters {clinic_id}, {patient_id}, {order_id} but your GetOrderRequest message only defines clinic_id adding the missing fields to your request message should fix this
I'm going to close this since it seems like it was a user error, please let me know if this issue persists!