Pact provider version/branch not set breaking selectors in CI
The provider version and branch anchor several broker features: publishing verification results, computing pending status, and resolving matchingBranch selectors. When they are unset, results are not attributable and branch-aware selection breaks.
What this error means
Verification runs but warns that provider version or branch is missing, results are not published, or matchingBranch selectors return no consumer pacts.
WARN: providerVersion is not set; verification results will not be published.
WARN: providerVersionBranch is not set; pending and matchingBranch selection disabled.Common causes
Provider version or branch env vars are empty
The verifier options read from empty variables, so the broker has no version or branch to attribute results to.
Detached HEAD hides the branch name in CI
A checkout in detached HEAD makes rev-parse --abbrev-ref HEAD return "HEAD", so the branch is effectively unset.
How to fix it
Set version and branch explicitly
- Pass
providerVersionfrom the commit sha. - Pass
providerVersionBranchfrom the CI-provided branch name. - Avoid relying on
rev-parseunder detached HEAD.
new Verifier({
provider: 'orders-provider',
providerVersion: process.env.GITHUB_SHA,
providerVersionBranch: process.env.GITHUB_REF_NAME,
publishVerificationResult: true,
})Resolve the branch under detached HEAD
Use the CI-provided ref name rather than git, which reports "HEAD" on a detached checkout.
env:
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}How to prevent it
- Always set provider version and branch from CI-provided variables.
- Do not derive the branch from git under detached HEAD.
- Publish verification results with a real provider version.