Ok, I'll need to look into these. I haven't tried ...
# protobufs
u
Ok, I'll need to look into these. I haven't tried messages within messages, so the descriptors may be encoded differently.
👍 2
s
hello @uglyog, any progress or updates?
u
Sorry, didn't get a chance to look into this, I'll see if I can do it next week
s
Sure!
u
0.1.15
has been released with fixes for the enums and embedded messages types
j
embedded message types is working. having a bit of difficulty getting enums working. I'll need to consult with @Sri Naga Sai Krishna Sanka
Ok, we figured out the proper syntax for enums is to use the actual enum:
"ad_break_type", AdBreakAdType.AUDIO_AD_BREAK
However, the contract that is produced doesn't have anything in the request body for
ad_break_type
and when I run the
pact_verifier_cli
, the provider complains with this error:
com.pandora.delivery.dispatch.api.exception.InvalidRequestParameterException: Invalid Request Parameter: AdBreakAdType is missing or invalid
I've attached the generated contract
u
I didn't have to use the actual enum, just the string value, but that was in Java, so maybe Go is different
j
If I try the string value
"ad_break_type", "matching(type, 'AUDIO_AD_BREAK')"
I get this error:
Failed to process protobuf: Protobuf enum value .delivery.dispatch.AdBreakAdType has no value AUDIO_AD_BREAK
we're using Java too 🤷
u
That was the old error, have you upgraded the plugin version?
s
yep the upgraded plugin version is being used. You can verify that in the
.json
file @Jason Army has provided
u
Ok, let me look into that, when you are using a matcher. Maybe I missed something.
s
With or without matcher, the plain string isn’t working.
u
Can you make sure you don't have multiple versions of the plugin installed? There is an issue where it will load the first plugin it finds.
j
I removed the other plugins but I'm still facing the same issue with
0.1.15
j
@Jason Army did the enum issue get sorted out? also having trouble getting enum to work in go
@uglyog any thoughts? trying to get an enum working based off the go gRPC example and having similar issue trying to sort out a valid enum value. on 0.1.17 https://github.com/pact-foundation/pact-go/blob/3bb31bcc34a19e984bea58117cadb72b9856a8df/examples/grpc/grpc_consumer_test.go#L44
Copy code
Protobuf enum value .authz.v2.EnforceEffect has no value ENFORCE_EFFECT_ALLOW
meant 0.1.15
u
I'll look into this now
I can't replicate this issue. With the latest plugin (0.1.15), enums work fine for me. I tried using direct values, matching them by type and also include the enum from another proto file. They all seem to work. Could someone kindly create an example project that displays the issue you are having?
j
do you have the syntax you are using for go to do the enum match?
am using this for match:
Copy code
"result": "TEST_TWO"
it works if i put the enum def inside the message. but if enum is outside it fails
Copy code
enum TestEnum {
     TEST_ONE = 0;
     TEST_TWO = 1;
     TEST_THREE = 2;
}

message TestResponse {
    TestEnum result = 1;
}
u
Is this in the consumer test or provider verification?
j
in the consumer test
u
I used both
"result": "TEST_TWO"
and
"result": "matching(type, 'TEST_TWO')"
j
ok - both of those work if i have the enum in the message but not if enum is outside
will try to narrow it down further with a minimal example next week
👍 1
A modified route_guide.proto to exhibit the behavior. Seemed tied to the package name having
.v2
, but then was also seeing additional odd behavior when I transferred the enum to route_guide. The file below is not hitting the enum issue with`"pact:proto-service": "RouteGuide/GetFeature"` but fails with
"pact:proto-service": "Test/GetFeature2"
. Dropping the
.v2
or moving the enum into the message makes the second case work.
Copy code
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     <http://www.apache.org/licenses/LICENSE-2.0>
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";


package routeguide.v2;


enum TestEnum {
  VALUE_ZERO = 0;
  VALUE_ONE = 1;
  VALUE_TWO = 2;
}

// Points are represented as latitude-longitude pairs in the E7 representation
// (degrees multiplied by 10**7 and rounded to the nearest integer).
// Latitudes should be in the range +/- 90 degrees and longitude should be in
// the range +/- 180 degrees (inclusive).
message Point {
  int32 latitude = 1;
  int32 longitude = 2;
}

// A latitude-longitude rectangle, represented as two diagonally opposite
// points "lo" and "hi".
message Rectangle {
  // One corner of the rectangle.
  Point lo = 1;

  // The other corner of the rectangle.
  Point hi = 2;
}

// A feature names something at a given point.
//
// If a feature could not be named, the name is empty.
message Feature {
  TestEnum result = 1;
}

// A RouteNote is a message sent while at a given point.
message RouteNote {
  // The location from which the message is sent.
  Point location = 1;

  // The message to be sent.
  string message = 2;
}

// A RouteSummary is received in response to a RecordRoute rpc.
//
// It contains the number of individual points received, the number of
// detected features, and the total distance covered as the cumulative sum of
// the distance between each point.
message RouteSummary {
  // The number of points received.
  int32 point_count = 1;

  // The number of known features passed while traversing the route.
  int32 feature_count = 2;

  // The distance covered in metres.
  int32 distance = 3;

  // The duration of the traversal in seconds.
  int32 elapsed_time = 4;
}

// Interface exported by the server.
service Test {
  // A simple RPC.
  //
  // Obtains the feature at a given position.
  //
  // A feature with an empty name is returned if there's no feature at the given
  // position.
  rpc GetFeature2(Point) returns (Feature) {}

  // A server-to-client streaming RPC.
  //
  // Obtains the Features available within the given Rectangle.  Results are
  // streamed rather than returned at once (e.g. in a response message with a
  // repeated field), as the rectangle may cover a large area and contain a
  // huge number of features.
  rpc ListFeatures(Rectangle) returns (stream Feature) {}

  // A client-to-server streaming RPC.
  //
  // Accepts a stream of Points on a route being traversed, returning a
  // RouteSummary when traversal is completed.
  rpc RecordRoute(stream Point) returns (RouteSummary) {}

  // A Bidirectional streaming RPC.
  //
  // Accepts a stream of RouteNotes sent while a route is being traversed,
  // while receiving other RouteNotes (e.g. from other users).
  rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
}
u
Thanks for that. 0.1.16 released with the fix