Hey folks, I've run into what I suspect may be a b...
# protobufs
s
Hey folks, I've run into what I suspect may be a bug. I have a grpc service which responds with a message that has a single boolean field (proto has more fields, but those are not populated by this service). Whenever the server responds with
false
in that field (i can adjust the state in the test), I'm getting this error from the protobuf plugin:
Copy code
1) Verifying a pact between <consumer> and <provider> - <message>
2024-01-25 17:53:27.1661  ┃     1.1) has a matching body
2024-01-25 17:53:27.1661  ┃            $ -> Expected message '<message>' but was missing or empty
This happens regardless of whether consumer expects true or false. The server seems to respond with a correct message, seeing how changing the state to return
true
makes the plugin work correctly, passing if the consumer requested true and failing if the consumer requested false. This could be because boolean false is default, so the plugin cannot distinguish empty response from the explicit false, or am I misreading this?
According to the logs,
decode_message
returns empty for such a proto, here: https://github.com/pactflow/pact-protobuf-plugin/blob/main/src/message_decoder/mod.rs#L258
Copy code
2024-01-26T01:32:33.300435Z  INFO tokio-runtime-worker request{method=POST uri=<http://127.0.0.1:57435/io.pact.plugin.PactPlugin/VerifyInteraction> version=HTTP/2.0 headers={"te": "trailers", "content-type": "application/grpc", "authorization": Sensitive, "user-agent": "tonic/0.9.2"}}:decode_message: pact_protobuf_plugin::message_decoder: return=Ok([])
r
Oh, it's probably because false is the default, Protobuf is dropping the field from the payload. It does the same thing with enums.
I'll see if I can replicate it.
0.3.10 released which should have better support for default values
superman 1
thankyou 2 1