Hello. My colleagues <@U03M3TJ23QE>, <@U02611UH0EQ...
# protobufs
j
Hello. My colleagues @Sri Swetha Somepalli, @Sri Naga Sai Krishna Sanka, and I have been looking into the gRPC plugin but cannot find a way to get the pact libraries to build requests from imported .proto files. Basically, any request that contains portions included in another proto file don't end up in the contract. Here's how I illustrated this in my fork of `pact-plugins`: 1. Add
common.proto
into
examples/gRPC/area_calculator/proto
2. Add
import "common.proto"
into
area_calculator.proto
and add
DeviceContext
and
ListenerContext
3. Modify the
request
in
PactConsumerTest.calculateRectangleArea
as follows:
Copy code
"request", Map.of(
          "device_context", Map.of(
              "device_id", "matching(number, 4)",
              "carrier_name", "matching(type, 'foo')"
          )),
          "listener_context", Map.of(
              "listener_id", "matching(number, 1)"
          ),
Now when you run the
PactConsumerTest
the generated
grpc-consumer-jvm-area-calculator-provider.json
does not contain the
listener_context.listener_id
. I'll attach the generated pact along with plugin.log in the thread
plugin.log.2022-09-15,grpc-consumer-jvm-area-calculator-provider.json
u
Ok, let me look into this for you.
👍 2
I've released 0.1.14 of the plugin with a fix for fields from imports
👀 1
m
oh, does this mean the protobuf plugin can resolve relative file imports?
u
The plugin just delegates to protoc, so it's whatever protoc does
👍 1
s
We tried the 0.1.14, it is currently working as desired. However, we are having stub generation problems, if we comment it out, it’s working out fine. Will let you know more. Thank you!
👍 1
Hello guys, we are currently experiencing
InvalidProtocolBufferException: Protobuf message had a invalid wire type
. We are not very big on protobufs. Upon trying the example you’ve provided, it’s going through. With our example, it’s not. The error is specifically happening at
parseFrom
line in the pact test. Any help is appreciated. TIA
j
We've solved the
invalid wire type
issue. The .proto we were using in the test did not match the version in the proto library so they were encoded differently