Closed wtrep closed 1 year ago
@wtrep this was a miss on my part. I wrongly assumed that trying to unmarshal no data should be an error.
That snippet in the generated code should just return nil
instead of an error and leave the message unmodified. Happy to review a PR if you want to submit one. If not, I'll fix this as soon as I finish up some other in-flight work I have.
The templates are here and you'd need to update both singlefile.go.tmpl
and permessage.go.tmpl
. Go text templates aren't great at sharing code. 😢
No problem ! I'll submit a PR
@wtrep I had some spare bandwidth so I went ahead and knocked this out. This should resolve your issue.
Thanks @dylan-bourque !
@wtrep I just tagged v0.18.0. Let me know if that doesn't work for you.
Title
protoc-gen-fastmarshal
generated code fails to unmarshal empty protov2 messageVersion
0.14.0
Description
Reflection-free generated code (
*.pb.fm.go
) doesn't seem to support "unmarshalling" empty messages.The Unmarshal method first validates that the buffer isn't empty:
This seems to not support empty messages.
Repro steps
package bogus.v1alpha1;
option go_package = "github.com/bogus/api/proto/v1alpha1";
message BogusRequest {}
message BogusResponse { string response = 1; }
service BogusService { rpc BogusEmptyBody(BogusRequest) returns (BogusResponse) {} }
Make a simple request:
Comment out
encoding.RegisterCodec(csproto.GrpcCodec{})
Validate that it works now: