Search code examples
javascriptjestjspactpact-broker

pactFileWriteMode overwrite not working anymore in Pact


We got our Pact broker updated to 2.107.1 last week, but since then we are getting issues when we push any changes to pact with the same version number. Before this update it would just overwrite the file with the same version number.

We have a property in our consumer config "pactFileWriteMode" and we have it set to "overwrite". It has worked fine until now. But with this update, not anymore.

Any ideas?


Solution

  • The write mode is not a mode related to the broker, but the local Pact library.

    It was removed in the 10.x.x line of code (see https://github.com/pact-foundation/pact-js/blob/master/MIGRATION.md#beta61).

    I think you want to enable the allow_dangerous_contract_modification feature:

    Whether or not to allow the pact content for an existing consumer version to be modified. It is strongly recommended that this is set to false, as allowing modification makes the results of can-i-deploy unreliable. When this is set to false as recommended, each commit must publish pacts with a unique version number.

    If modification of an existing contract is attempted when the value is set to false, an HTTP 409 status will be returned.

    See https://docs.pact.io/pact_broker/configuration/settings#allow_dangerous_contract_modification.

    Just note that this is not recommended and can result in false positives in calls to can-i-deploy.