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

PactBrokerClient throws index-out-of-bounds when 'can-i-deploy' is called for a new tag #1814

Closed
alwidas opened this issue Jul 11, 2024 · 3 comments
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

@alwidas
Copy link

alwidas commented Jul 11, 2024

We are using the maven-plugin (au.com.dius.pact.provider:maven:4.5.10` for most of our PACT Steps during CI & Deployment.

Whenever we try to call can-i-deploy for a provider on a new tag (no consumers yet!), it fails with

Execution default-cli of goal au.com.dius.pact.provider:maven:4.5.10:can-i-deploy failed: Index 0 out of bounds for length 0

The cause is obvious. When we ask with a (not yet) known tag, the server (PactFlow) sends this JSON response:

{
  "summary": {
    "deployable": true,
    "reason": "There are no missing dependencies",
    "success": 0,
    "failed": 0,
    "unknown": 0
  },
  "notices": [
    {
      "type": "success",
      "text": "There are no missing dependencies"
    }
  ],
  "matrix": []
}

=> "matrix" is an empty array

The code indeed checks if the array is null (?.), but after that it calls get(0) on the empty array.

val verificationResultUrl = result.value["matrix"].asArray()
?.get(0)?.asObject()

As this part is only executed to deliver the successful verification results, it should be no problem to skip that part entirely, if we don't have a result at all.
Sorry that i don't come up with a PR, but i'm not used to Kotlin at all, and the fix should be fairly easy to implement.

Interesting observation as a side note: when using the CLI (pact-broker), no error occurs.

@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 Jul 12, 2024
Copy link

🤖 Great news! We've labeled this issue as smartbear-supported and created a tracking ticket in PactFlow's Jira (PACT-2181). 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 Jul 12, 2024
rholshausen added a commit that referenced this issue Jul 12, 2024
@rholshausen
Copy link
Contributor

I've released 4.5.11 with the fix

rholshausen added a commit that referenced this issue Jul 12, 2024
@alwidas
Copy link
Author

alwidas commented Jul 15, 2024

Thank you so much for the incredibly fast reaction. Now it works as expected. 👍

@YOU54F YOU54F closed this as completed Jul 24, 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

3 participants