Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider branch not sent to Pact Broker in consumer version selectors if enablePending=false #1769

Open
misko321 opened this issue Feb 14, 2024 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear

Comments

@misko321
Copy link

If enablePending = false, the current provider branch name is NOT sent to the Pact Broker when fetching pacts to verify using consumer version selectors.

Because of that e.g. the matchingBranch() selector doesn't work, because the request sent to the Pact Broker doesn't contain which branch is the one to match:

Java code:

@PactBrokerConsumerVersionSelectors
public static SelectorBuilder consumerVersionSelectors() {
    return new SelectorBuilder()
            .matchingBranch()
            .mainBranch();
}

Request made to the Pact Broker by the Pact JVM library:

{
  "consumerVersionSelectors": [
    { "matchingBranch": true },
    { "mainBranch": true }
  ],
  "includePendingStatus": false
}

This results in the Pact Broker returning 400 Bad Request:

{
  "errors": {
    "consumerVersionSelectors": [
      "the providerVersionBranch must be specified when the selector matchingBranch=true is used (at index 0)"
    ]
  }
}

Cause of the issue

The branch name is sent only if enablePending = true. The piece of code responsible for that in PactBrokerClient.kt:

body["includePendingStatus"] = enablePending
if (enablePending) {
    body["providerVersionTags"] = jsonArray(providerTags)
    if (providerBranch.isNotEmpty()) {
        body["providerVersionBranch"] = providerBranch
    }
    if (includeWipPactsSince.isNotEmpty()) {
        body["includeWipPactsSince"] = includeWipPactsSince
    }
}

Why do I consider it a bug?

Using matchingBranch() with enablePending = false seems completely reasonable and the docs seem to confirm that:

matchingBranch() - The latest version from any branch of the consumer that has the same name as the current branch of the provider. Used for coordinated development between consumer and provider teams using matching feature branch names.

Enabling the pending pacts feature stops changed pacts breaking the main provider build. If you are automatically bringing in a pact using the "matching feature branch names" approach, you might want to disable this feature on your feature branches, so that a feature pact correctly fails the branch build until it is fully implemented, and then passes to let you know you can merge.

@misko321 misko321 changed the title Provider branch not sent to broker in consumer version selectors if enablePending=false Provider branch not sent to Pact Broker in consumer version selectors if enablePending=false Feb 14, 2024
@rholshausen rholshausen added bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear labels Feb 15, 2024
Copy link

🤖 Great news! We've labeled this issue as smartbear-supported and created a tracking ticket in PactFlow's Jira (PACT-1830). We'll keep work public and post updates here. Meanwhile, feel free to check out our docs. Thanks for your patience!

rholshausen added a commit that referenced this issue Feb 15, 2024
rholshausen added a commit that referenced this issue Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear
Projects
None yet
Development

No branches or pull requests

2 participants