-
Notifications
You must be signed in to change notification settings - Fork 8
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
Adding new fields to a provider and verifying against an older contract without the new fields seems to fail #53
Comments
Is there any movement on either a workaround for this or alternative approach as this is a key blocker to us using the pact protobuf plugin |
Upon further inspection of the logs, the new fields are being treadted as
Per the proto3 spec these unkown fields seem to be legitimate even though they may or may not be used by the older schema https://protobuf.dev/programming-guides/proto3/#unknowns |
After having a flick through the source code, it seems like |
After a bit more digging we seem to have found the issue: When the unknown field is written there seems to be an extra zero prepended to the field which appears to be causing the protobuf decoder to fail because it thinks it has found a field with a tag value of 0. |
Attaching full provider verification run for context |
👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-1942). 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. |
The issue was that the varint value for the boolean field was being captured as a u64 value (8 bytes), when a varint can be 1 to 10 bytes depending on the value. For a boolean value of true, it should be just 1 byte. This added an extra 7 zero bytes to the end of the message making it an invalid Protobuf message. |
Thanks Ron! @jdem4ine are you able to retest with 0.3.14 please? |
Going to assume this is complete, feel free to let us know if not |
We have an initial proto file like this:
Contracts have been generated for this interaction between a JS consumer and a go provider. These have been merged to main and deployed against one of our environments.
We then changed the structure of the response from the provider to be
This was done to ensure that the provider will support the change in contract i.e. the new
email
,email_verified
and the change fromsurname
tolast_name
as well as retain the fields from the previous contract such that it can be deployed to an environment where the old contract exists.When we tried to verify this contract against consumer versions using selectors (matching-branch, deployed and mainbranch)
NOTE: Here we are expecting less data than the provider provides (not expecting
created_at
updated_at
andsurname
)and all seems fine (like I would expect)2024-03-28T10:04:36.189948Z ERROR ThreadId(18) pact_verifier: Individual mismatch is an error: failed to decode Protobuf message: invalid tag value: 0
My suspicion is that when the contract comes from the broker for the main/deployed versions it is somehow wanting the provider to support the exact response it expects rather than just those fields as a minimum
The text was updated successfully, but these errors were encountered: