I have tried to invoke the endpoint that publishes...
# pact-jvm
s
I have tried to invoke the endpoint that publishes the contract with a similar body mentioned below and got a response:
Copy code
{
  "pacticipantName": "Foo",
  "pacticipantVersionNumber": "dc5eb529230038a4673b8c971395bd2922d8b240",
  "branch": "main",
  "tags": [
    "main"
  ],
  "buildUrl": "<https://ci/builds/1234>",
  "contracts": [
    {
      "consumerName": "Foo",
      "providerName": "Bar",
      "specification": "pact",
      "contentType": "application/json",
      "content": "<base64 encoded JSON pact>"
    }
  ]
}
Response:
Copy code
{
  "notices": [
    {
      "type": "error",
      "text": "Cannot change the content of the pact for ppe-service-ent-issue-compilation version 1.0.0 and provider ppe-service-ent-issue-compilation, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number. For more information see <https://docs.pact.io/go/versioning>"
    },
    {
      "type": "info",
      "text": ""
    }
  ],
  "errors": {
    "contracts": [
      "Cannot change the content of the pact for ppe-service-ent-issue-compilation version 1.0.0 and provider ppe-service-ent-issue-compilation, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number. For more information see <https://docs.pact.io/go/versioning>"
    ]
  }
}
I dont see any difference in the content that is causing this issue
m
Have you compared the versions to see the difference? My guess is the binary content is different
s
Hey Matt, the version available in the pact server is same as the version im trying to upload.. agreed there is an update in the pact json, but these logs are not helping to find the actual conflict and now all our services are failing to get deployed with this error
m
why are you using the same version though? Have you read the versioning guide?
s
im kinda new to this.. let me try to put it this way.. so we have this ppe-service-ent-issue-compilation consumer that has a version 1.0.0 and now that the provider is passing few more properties in the response.. so the provider pact is updated with the new values..
when i put this json locally and run pact verify it is working like a charm.. only when im connecting to the actual pact broker it is throwing this exception..
the version is handled automatically i guess
apologies if im speaking rubbish
Hi Matt, thanks for the suggestion, we have updated the version from 1.0.0 to 2.0.0 and it got published successfully, but I have question here: From last 3 years, we have been publishing the contract with the same version i.e. 1.0.0 and haven't come across this conflict error until now. Just wanted to know, if there is any cap under a specific version to have only a certain number of updates for a specific version?
And we were not updating the pact version because of the way we are handling our apis: • We do not maintain older versions of our apis • Normally versioning shows which consumer and provider versions are compatible • Thats not a requirement or even a scenario for us
m
You can disable this check, but it's not recommended. If you search the pact docs you should be able to find the setting (it has the word "dangerous" and "modification" in it I think). You may have upgraded the broker which has enabled this setting.
What do you mean you don't maintain older version of your APIs? That's not why versioning is important, it tracks the version of your code that is being deployed. I highly recommend reading the versioning guide and the CI/CD guide to understand what guarantees you might be missing out on
s
thanks Matt for the valuable comments, we will take it further to implement the best practices to be incorporated to handle the pact publishing strategy
👍 1
one last question, so are we saying that the pact broker update might be the reason for this exception to crop up?
m