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

Gradle task pactPublish fails (400 bad request) and does not print error message #1150

Closed
borwoj opened this issue Jun 29, 2020 · 2 comments
Closed

Comments

@borwoj
Copy link

borwoj commented Jun 29, 2020

Steps to reproduce

  1. Write a JUnit 5 test
  2. Run the test
  3. A contract JSON file is created
  4. Run ./gradlew pactPublish

Expected:

  • If success: 201 Created
  • If error: a detailed error message is presented

Actual:

> Task :pactPublish FAILED
PUT JSON request failed with status HTTP/1.1 400 Bad Request
Publishing 'Android App-Some Api.json' ... Failed

FAILURE: Build failed with an exception.

* What went wrong:
One or more of the pact files were rejected by the pact broker

However, publishing the exact same JSON to the exact same broker using cURL works just fine:

curl -X "PUT" "https://.../pacts/provider/Some%20Api/consumer/Android%20App/version/0.0.1
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{...}'

Response: 201 Created

Configuration

build.gradle (app level)

pact {
  publish {
    pactDirectory = 'app/target/pacts'
    pactBrokerUrl = 'https://...'
    pactBrokerUsername = '' // no authentication
    pactBrokerPassword = '' // no authentication
  }
}
...
testImplementation 'au.com.dius:pact-jvm-consumer-junit5:4.0.10'

build.gradle (project level)

plugins {
  id "au.com.dius.pact" version "4.1.2"
}

Do you have an idea of what may be needed for the publish task to work?

An issue related to missing error messages: #291

@borwoj borwoj changed the title Gradle task pactPublish fails and does not print error message Gradle task pactPublish fails (400 bad request) and does not print error message Jun 29, 2020
@uglyog
Copy link
Member

uglyog commented Aug 9, 2020

4.1.7 has been released with this fix

shilgam added a commit to shilgam/pact-workshop-jvm that referenced this issue Aug 30, 2020
to fix gradle task pactPublish failure (400 bad request)
Issue: pact-foundation/pact-jvm#1150
shilgam added a commit to shilgam/pact-workshop-jvm that referenced this issue Aug 31, 2020
To fix gradle task pactPublish failure (400 bad request).
Issue: pact-foundation/pact-jvm#1150
shilgam added a commit to shilgam/pact-workshop-jvm that referenced this issue Sep 2, 2020
* Consumer: Add the Gradle Pact plugin and tell it about Pact Broker

* Consumer: Bump au.com.dius.pact plugin version to 4.1.7

To fix gradle task pactPublish failure (400 bad request).
Issue: pact-foundation/pact-jvm#1150

* Dropwizard provider: Fetch pacts from Pact Broker

* Springboot provider: Fetch pacts from Pact Broker

* Springboot provider: Publish results back to Pact Broker

* Remove unused code and docs
@borwoj
Copy link
Author

borwoj commented Sep 2, 2020

4.1.7 solved the issue, thanks!

@borwoj borwoj closed this as completed Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants