Pact "Error publishing pact ... 409 Conflict" in CI
The broker refuses to overwrite an already-published pact for the same consumer version with different content. A 409 Conflict means you re-published the same version number with a changed contract.
What this error means
The publish step fails with "409 Conflict" and a message that the pact content for this consumer version already exists and differs from what is being published.
Error publishing pact to https://acme.pactflow.io
409 Conflict
Cannot change the content of the pact for web-consumer version 1.0.0
as it has already been published.Common causes
The consumer version is not unique per build
A static or rerun version number (like a fixed 1.0.0) got republished with different pact content, which the broker forbids.
Two jobs published different content under one version
Parallel or retried jobs used the same version string but produced slightly different pacts, triggering the conflict.
How to fix it
Use the git sha as the consumer version
- Derive a unique version from the commit sha for every publish.
- Pass it as
--consumer-app-version. - Never republish a version with changed content.
pact-broker publish ./pacts \
--consumer-app-version "$(git rev-parse --short HEAD)" \
--branch "$(git rev-parse --abbrev-ref HEAD)" \
--broker-base-url "$PACT_BROKER_BASE_URL"Make pact generation deterministic
Remove nondeterministic values from the pact so a re-run of the same commit produces identical content.
How to prevent it
- Version every publish by commit sha so content and version stay 1:1.
- Keep generated pacts deterministic across reruns.
- Do not publish a fixed version like 1.0.0 from CI.