Search code examples
pact

How to handle the workflow where provider makes breaking changes to consumer services?


As an example:

  • Provider updates a field that existing consumers consume.
  • The provider pushes up their changes, and triggers a provider verification within this provider build.
  • The provider verification tests against all consumers tagged with 'prod'.
  • The verification fails, as expected, since prod consumers are still expecting the unchanged version of the field.
  • Consumer services are notified, and makes appropriate changes to their expectations, and publishes the contracts to the broker.
  • Webhook triggers a provider verification.

This is where I'm lost. In this step of the provider verification, do we explicitly want our provider to check out the branch that contains the change to be used for the provider verification? Because if we use the production version of the provider here, the verification would fail since the changed fields aren't yet available.


Solution

  • This guide explains the process and should clarify for you: https://docs.pact.io/pact_nirvana

    But more generally, I think you mostly want to add breaking changes into a system that are backwards compatible initially and so don't require such coupling. So first, if you're changing/breaking a field in an API, I would have consumers first stop using the field (or if you can use the expand/contract approach where you add a new field with the new behaviour, go that way) and get them into production. Then it won't matter what branch the changes run against. But the tagging/branching section in the aforementioned docs should help if you don't want to go that way.