-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
🐛 Bug Report
I have two messages
message DeleteBookRequest {
string shelf_id = 1; // The ID of the shelf containing the book.
string book_id = 2; // The ID of the book to delete.
}
message DeleteBookResponse {}
And there is a readWrite service
service ReadWriteService {
rpc DeleteBook(DeleteBookRequest) returns (DeleteBookResponse) {
option (google.api.http) = {
delete: "/v1/shelves/{shelf_id}/books/{book_id}"
};
}
}
To Reproduce
- Create messages and a service in
*.proto - run
buf generate - check
*.pb.gw.gofile
Expected behavior
There is no errors and I can run for example go run
Actual Behavior
I have the next errors in *.pb.gw.go
for example this func
func request_ReadWriteService_DeleteBook_0(ctx context.Context, marshaler runtime.Marshaler, client ReadWriteServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq DeleteBookRequest
metadata runtime.ServerMetadata
err error
)
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
val, ok := pathParams["shelf_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "shelf_id")
}
protoReq.ShelfId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "shelf_id", err)
}
val, ok = pathParams["book_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "book_id")
}
protoReq.BookId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "book_id", err)
}
msg, err := client.DeleteBook(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
As you can see on the screen, protoReq with type DeleteBookRequest
P.S. The type DeleteBookRequest from *.pb.go
type DeleteBookRequest struct {
state protoimpl.MessageState `protogen:"opaque.v1"`
xxx_hidden_ShelfId *string `protobuf:"bytes,1,opt,name=shelf_id,json=shelfId"`
xxx_hidden_BookId *string `protobuf:"bytes,2,opt,name=book_id,json=bookId"`
XXX_raceDetectHookData protoimpl.RaceDetectHookData
XXX_presence [1]uint32
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
So, protoReq doesn't have both ShelfId and BookId
Your Environment
go version go1.25.3
Metadata
Metadata
Assignees
Labels
No labels