Hi, I have an issue when my consumer has triggered...
# pact-jvm
t
Hi, I have an issue when my consumer has triggered my Github Action towards the provider, to verify the pact. The webhook contains a payload that contains the "${pactBroker.pactUrl}" that has been resolved in the Pact Broker. The issue is that is does not contain the
pb:latest-provider-pacts
entry, and the test fails. The Pact Broker version is
2.98.0
and the junit5 lib (
au.com.dius.pact.provider:junit5
) is version
4.3.6
. I would very much like some assistance as to where I should investigate...
The test error is:
Copy code
au.com.dius.pact.core.pactbroker.InvalidHalResponse: Link 'pb:latest-provider-pacts' was not found in the response, only the following links where found: [self, pb:consumer, pb:consumer-version, pb:consumer-versions, pb:provider, pb:pact-version, pb:latest-pact-version, pb:all-pact-versions, pb:latest-untagged-pact-version, pb:latest-tagged-pact-version, pb:previous-distinct, pb:diff-previous-distinct, pb:diff, pb:pact-webhooks, pb:consumer-webhooks, pb:tag-prod-version, pb:tag-version, pb:publish-verification-results, pb:latest-verification-results, pb:triggered-webhooks, pb:matrix-for-consumer-version, curies]. URL: 'https://[...]/pacts/provider/{provider}/consumer/{consumer}/pact-version/6694147efd97f837b4bd892d11cc074d77b50a90/metadata/Y3ZuPWUwM2UyMjc0Mzc1ZTRhYWZkY2QyYjU4OWIyMDkzYTNkYWQ0ZjdmMzQmdz10cnVl', LINK: 'pb:latest-provider-pacts'
(Link has been abbreviated)
The sysProps supplied to the test are:
Copy code
<pactbroker.url>${env.PACT_URL}</pactbroker.url>
<pact.provider.version>${env.GITHUB_SHA}</pact.provider.version>
<pact.provider.branch>${env.GITHUB_BRANCH}</pact.provider.branch>
<pact.provider.tag>${env.GITHUB_BRANCH}</pact.provider.tag>
The PACT_URL is taken from the webhook body.
r
This may be a bug, can you raise an issue with that
t
@rholshausen Would there be an issue with missing annotations perhaps?
Copy code
@Provider("name-of-provider")
@PactBroker
@IgnoreNoPactsToVerify
class X ...
I tried adding consumerVersionSelectors, but that still end up with same error. It gets to the end of
<http://au.com|au.com>.dius.pact.core.pactbroker.PactBrokerClient#fetchConsumersWithSelectors
where it calls
fetchConsumersWithTag
which breaks because of missing link.
I opened a ticket
m
The issue is that you’re putting the dynamic value
PACT_URL
(the path to the contract that needs to be verified) in a property that needs the base URL of a Pact Broker to dynamically discover pacts:
<pactbroker.url>${env.PACT_URL}</pactbroker.url>
. It can’t find the correct relation to navigate to, because the request is not sent to the correct starting point.
The maven command is then makinsg a call to
PACT_URL
with any configured selectors to discover pacts to verify. But this is not what you want.
What you want, I think, is
pactSource
. I’m not sure how to configure this behaviour dynamically, but I believe it to be the source of the issue
t
@Matt (pactflow.io / pact-js / pact-go) Oh thank you for assisting! 🙏 I do indeed use this the way you state; I took the inspiration from https://docs.pact.io/pact_broker/webhooks/template_library#github---trigger-build which says to do like this. Obviously I am missing out on something more.. 😞
So, I want to find a way to use this url not as a baseUrl but instead as a PactSource.
m
exactly.
I don’t know how to do that with maven which tends to be quite declarative. I’m hoping/guessing there is a system property way of doing it
pact.filter.pacturl
from https://docs.pact.io/implementation_guides/jvm/docs/system-properties seems helpful. Hopefully it flows through to Maven
Overrides the URL to use to fetch the Pacts to verify. This should be used when a webhook from the Pact broker has triggered the build.
t
As long as it is fetched from a sysProp, I got it covered.
👍 1
Sincere thanks, Matt!
👍 1
m
disclaimer: I’m just guessing on the properties, but worth a shot!
t
It is the best I got so far 🏆
🙏 1