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

Fetching pacts from broker for an unknown provider should fail gracefully #356

Closed
alonpeer opened this issue Dec 23, 2016 · 4 comments
Closed

Comments

@alonpeer
Copy link
Contributor

alonpeer commented Dec 23, 2016

I'm adding a verification step for a new provider service, which still doesn't have any consumer pacts written for, and so no pacts exist for it on our pact broker (it's not a participant in the broker yet). This means that http://pact-broker/pacts/provider/new_provider/latest returns a 404 Not Found.

This should be considered OK by pact-jvm, because I don't think it makes sense to manually push some provider info to pact-broker just so that it doesn't fail, until a real pact is pushed by some consumer.

At the moment, HalClient fails with:

DEBUG au.com.dius.pact.provider.broker.HalClient - Fetching: http://pact-broker/pacts/provider/new_provider/latest
au.com.dius.pact.provider.PactVerifierException: Failed to load pacts from pact broker at 'http://pact-broker'
...
Caused by: groovyx.net.http.HttpResponseException: Not Found
	at groovyx.net.http.RESTClient.defaultFailureHandler(RESTClient.java:263)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1215)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1082)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
	at groovy.lang.Closure.call(Closure.java:414)
	at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:503)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:222)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
	at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
	at groovyx.net.http.RESTClient.get(RESTClient.java:119)
	at groovyx.net.http.RESTClient$get.call(Unknown Source)
	at au.com.dius.pact.provider.broker.HalClient.fetch(HalClient.groovy:96)
...
@alonpeer
Copy link
Contributor Author

This is reproducible with pact-jvm-provider-sbt 2.4.17.

I'm looking at the master branch of pact-jvm, obviously the code is different there. I'm not sure why InvalidHalResponse is handled in 2.4.17 but not in master. So I don't know on which branch to apply a fix.

@uglyog
Copy link
Member

uglyog commented Dec 28, 2016

I think a flag to ignore missing pacts would be best, because in other cases a missing pact would be a problem and we would not want to have the build pass.

I'll look into the differences between 2.4.x branch and master, they should be similar.

uglyog pushed a commit that referenced this issue Dec 29, 2016
@uglyog
Copy link
Member

uglyog commented Dec 30, 2016

Version 2.4.18 has been released with your changes.

@alonpeer
Copy link
Contributor Author

Amazing, thanks!

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