Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky google.protobuf.Struct matching #71

Closed
becdot opened this issue Aug 8, 2024 · 6 comments
Closed

Flaky google.protobuf.Struct matching #71

becdot opened this issue Aug 8, 2024 · 6 comments
Labels
bug Something isn't working smartbear-supported Issues with this label have been added to the Pactflow team's Jira backlog

Comments

@becdot
Copy link

becdot commented Aug 8, 2024

Hi! I have a question about struct matching, and I'm feeling kind of stumped. I have a proto with a struct field, e.g.

message Request {
  string name = 1;
  google.protobuf.Struct params = 2;
}

In my test, I am creating a new struct

params, err := structpb.NewStruct(map[string]any{"kind": "general", "message": "test" })

and then marshaling it to JSON. The string I am passing to withContents looks like this

{"pact:proto":"whatever.proto","pact:proto-service":"Service/Endpoint","pact:content-type":"application/protobuf","request":{"name":"name","params":{"kind":"general","message":"test"}},"response":{"responses":[{"success":true,"id":"test123"}]}}

I run the test once and get this error

Received generate templates error rpc error: code = FailedPrecondition desc = Failed to match the request message - BodyMismatches({"$.params": [BodyMismatch { path: "$.params.fields.key", expected: Some(b"\"message\""), actual: Some(b"\"kind\""), mismatch: "Expected 'kind' (String) to be equal to 'message' (String)" }, BodyMismatch { path: "$.params.fields.value.string_value", expected: Some(b"\"test\""), actual: Some(b"\"general\""), mismatch: "Expected 'general' (String) to be equal to 'test' (String)" }]})

and then I run the test again (changing nothing, with exact same contents string) and it passes.

My best guess is that something weird is happening with ordering – I dug into the trace logs, and as far as I could tell, sometimes the matching code finds the keys in the order ABAB (works) and sometimes it finds the keys in the order ABBA (doesn't work).

Let me know if I can provide additional logs / info – thanks so much for taking a look!

@rholshausen rholshausen added bug Something isn't working smartbear-supported Issues with this label have been added to the Pactflow team's Jira backlog labels Aug 9, 2024
Copy link

👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-2313). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps.

See our documentation for more information.

@rholshausen
Copy link
Contributor

0.5.1 released with a fix for this

@becdot
Copy link
Author

becdot commented Sep 10, 2024

Amazing, thank you! 🥰

@YOU54F
Copy link
Member

YOU54F commented Sep 13, 2024

Hey @becdot, are you able to confirm if this resolves for you, when you are able to upgrade. ty!

@becdot
Copy link
Author

becdot commented Sep 16, 2024

@YOU54F yes, thank you for following up! Just added a few extra keys to my struct and ran the test several times and we seem to be golden!

@YOU54F
Copy link
Member

YOU54F commented Sep 16, 2024

lovely stuff. Thanks for the fix @rholshausen

@YOU54F YOU54F closed this as completed Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working smartbear-supported Issues with this label have been added to the Pactflow team's Jira backlog
Projects
None yet
Development

No branches or pull requests

3 participants