Hey folks, I'm experiencing some problems with pac...
# pact-broker
s
Hey folks, I'm experiencing some problems with pact provider verification via the new ``contract_requiring_verification_published`` webhook. My pact broker is hosted on sh1989.pactflow.io The error I receive is:
pact_1 | bundler: failed to load command: /pact/bin/pact (/pact/bin/pact)
pact_1 | /usr/lib/ruby/gems/3.0.0/gems/pact-1.63.0/lib/pact/hal/entity.rb53in `_link!': Could not find relation 'pb:latest-provider-pacts' in resource at https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b23699154f9342895ea8bac8e8d79396e3/metadata/Y3ZuPWRmMTgwMmI2Jnc9dHJ1ZQ (PacthalRelationNotFoundError)
This is what comes back from `GET /pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b23699154f9342895ea8bac8e8d79396e3/metadata/Y3ZuPWRmMTgwMmI2Jnc9dHJ1ZQ`:
Copy code
"{\"consumer\":{\"name\":\"pact-consumer\"},\"interactions\":[{\"_id\":\"f0f5cbd6bdb420b5c2bc3fbf4ec719ea5304fe11\",\"description\":\"A request for quotes\",\"providerStates\":[{\"name\":\"a comedy-loving user\"}],\"request\":{\"method\":\"GET\",\"path\":\"/quotes\"},\"response\":{\"body\":[{\"author\":\"Rick Sanchez\",\"quote\":\"I'm Pickle Rick!\",\"source\":\"<https://www.imdb.com/title/tt5218268/>\"}],\"headers\":{\"Content-Type\":\"application/json\"},\"matchingRules\":{\"body\":{\"$\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"type\",\"min\":1}]},\"$[*].source\":{\"combine\":\"AND\",\"matchers\":[{\"match\":\"regex\",\"regex\":\"http(s)?://([^?#]*)\"}]}}},\"status\":200}},{\"_id\":\"10bbe0048033bcb9069f50ec34714735737e7508\",\"description\":\"A request for quotes\",\"providerStates\":[{\"name\":\"no user\"}],\"request\":{\"method\":\"GET\",\"path\":\"/quotes\"},\"response\":{\"status\":200}}],\"metadata\":{\"pact-js\":{\"version\":\"10.4.0\"},\"pactRust\":{\"ffi\":\"0.3.15\",\"models\":\"1.0.1\"},\"pactSpecification\":{\"version\":\"3.0.0\"}},\"provider\":{\"name\":\"pact-provider\"},\"createdAt\":\"2022-12-14T21:19:53+00:00\",\"_links\":{\"self\":{\"title\":\"Pact\",\"name\":\"Pact between pact-consumer (df1802b6) and pact-provider\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/version/df1802b6>\"},\"pb:consumer\":{\"title\":\"Consumer\",\"name\":\"pact-consumer\",\"href\":\"<https://sh1989.pactflow.io/pacticipants/pact-consumer>\"},\"pb:consumer-version\":{\"title\":\"Consumer version\",\"name\":\"df1802b6\",\"href\":\"<https://sh1989.pactflow.io/pacticipants/pact-consumer/versions/df1802b6>\"},\"pb:consumer-versions\":[{\"title\":\"Consumer version\",\"name\":\"df1802b6\",\"href\":\"<https://sh1989.pactflow.io/pacticipants/pact-consumer/versions/df1802b6>\"}],\"pb:provider\":{\"title\":\"Provider\",\"name\":\"pact-provider\",\"href\":\"<https://sh1989.pactflow.io/pacticipants/pact-provider>\"},\"pb:pact-version\":{\"title\":\"Pact content version permalink\",\"name\":\"70a8e3b23699154f9342895ea8bac8e8d79396e3\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b23699154f9342895ea8bac8e8d79396e3>\"},\"pb:latest-pact-version\":{\"title\":\"Latest version of this pact\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/latest>\"},\"pb:all-pact-versions\":{\"title\":\"All versions of this pact\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/versions>\"},\"pb:latest-untagged-pact-version\":{\"title\":\"Latest untagged version of this pact\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/latest-untagged>\"},\"pb:latest-tagged-pact-version\":{\"title\":\"Latest tagged version of this pact\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/latest/{tag}>\",\"templated\":true},\"pb:previous-distinct\":{\"title\":\"Previous distinct version of this pact\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/version/df1802b6/previous-distinct>\"},\"pb:diff-previous-distinct\":{\"title\":\"Diff with previous distinct version of this pact\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/version/df1802b6/diff/previous-distinct>\"},\"pb:diff\":{\"title\":\"Diff with another specified version of this pact\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b23699154f9342895ea8bac8e8d79396e3/diff/pact-version/{pactVersion}>\",\"templated\":true},\"pb:pact-webhooks\":{\"title\":\"Webhooks for the pact between pact-consumer and pact-provider\",\"href\":\"<https://sh1989.pactflow.io/webhooks/provider/pact-provider/consumer/pact-consumer>\"},\"pb:consumer-webhooks\":{\"title\":\"Webhooks for all pacts with provider pact-provider\",\"href\":\"<https://sh1989.pactflow.io/webhooks/consumer/pact-provider>\"},\"pb:tag-prod-version\":{\"title\":\"PUT to this resource to tag this consumer version as 'production'\",\"href\":\"<https://sh1989.pactflow.io/pacticipants/pact-consumer/versions/df1802b6/tags/prod>\"},\"pb:tag-version\":{\"title\":\"PUT to this resource to tag this consumer version\",\"href\":\"<https://sh1989.pactflow.io/pacticipants/pact-consumer/versions/df1802b6/tags/{tag}>\"},\"pb:publish-verification-results\":{\"title\":\"Publish verification results\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b23699154f9342895ea8bac8e8d79396e3/metadata/Y3ZuPWRmMTgwMmI2Jnc9dHJ1ZQ/verification-results>\"},\"pb:latest-verification-results\":{\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b23699154f9342895ea8bac8e8d79396e3/verification-results/latest>\"},\"pb:triggered-webhooks\":{\"title\":\"Webhooks triggered by the publication of this pact\",\"href\":\"<https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/version/df1802b6/triggered-webhooks>\"},\"pb:matrix-for-consumer-version\":{\"title\":\"View matrix rows for the consumer version to which this pact belongs\",\"href\":\"<https://sh1989.pactflow.io/matrix?q[][pacticipant]=pact-consumer>\\u0026q[][version]=df1802b6\\u0026latestby=cvpv\"},\"curies\":[{\"name\":\"pb\",\"href\":\"<https://sh1989.pactflow.io/doc/{rel}?context=pact>\",\"templated\":true}]}}"
And the command that the webhook triggers:
Copy code
pact verify <https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b23699154f9342895ea8bac8e8d79396e3/metadata/Y3ZuPWRmMTgwMmI2Jnc9dHJ1ZQ>
      --provider pact-provider
      --provider-app-version 6a774a4
      --provider-version-branch master
      --provider_base_url <http://app:8081>
      --provider-states-setup-url <http://app:8081/provider-states>
      --pact-broker-base-url <https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b23699154f9342895ea8bac8e8d79396e3/metadata/Y3ZuPWRmMTgwMmI2Jnc9dHJ1ZQ>
      --broker-token <redacted>
      --wait 10
      --verbose true
m
Can you please share the full verbose output?
b
You base URL is wrong.
party parrot 1
It should be
Copy code
--pact-broker-base-url <https://sh1989.pactflow.io>
that’s an unusual combination of attributes
you either want to set your
--pact-broker-base-url
and
--provider
OR you set the pact URL.
you shouldn’t be setting both.
when you do a verification, either you’re verifying a changed pact at a specific URL, passed in via the webhook (so, just provide the pact URL parameter) OR you’re doing a verification of all the provider’s pacts because the provider has changed (in which case, you set the base URL and the provider name)
Copy code
pact verify <https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b23699154f9342895ea8bac8e8d79396e3/metadata/Y3ZuPWRmMTgwMmI2Jnc9dHJ1ZQ>
      --provider-app-version 6a774a4
      --provider-version-branch master
      --provider_base_url <http://app:8081>
      --provider-states-setup-url <http://app:8081/provider-states>
      --broker-token <redacted>
      --wait 10
      --verbose true
OR
Copy code
pact verify 
      --provider pact-provider
      --pact-broker-base-url <https://sh1989.pactflow.io>
      --provider-app-version 6a774a4
      --provider-version-branch master
      --provider_base_url <http://app:8081>
      --provider-states-setup-url <http://app:8081/provider-states>
      --broker-token <redacted>
      --wait 10
      --verbose true
s
Thanks Beth! If I run the first option, I get the error:
No value provided for required option '--provider'
But once I added that back in too it worked correctly 🙂 and glad it was something simple! I was also a bit confused by the documentation here https://docs.pact.io/provider/recommended_configuration, which says that "When the pact URL is known, the
pactBrokerUrl
,
providerName
,
consumerVersionSelectors/consumerVersionTags
,
enablePending
,
includeWipPactsSince
fields should not be set" - but maybe that's specific to the JS/Ruby libs rather than via the CLI
b
No, same recommendation @Sam Hogarth
it’s the same underlying code.
Can you send me the exact command and error stack for when you saw
No value provided for required option '--provider'
because that error doens’t seem right.
and the version of the CLI
s
Of course, gimme a few hours
Running
pactfoundation/pact-cli
docker container with digest
sha256:e0a783b0
(v0.51.0), here's the output from my terminal:
Copy code
docker run --rm pactfoundation/pact-cli:latest pact verify \
> <https://sh1989.pactflow.io/pacts/provider/pact-provider/consumer/pact-consumer/pact-version/70a8e3b>
23699154f9342895ea8bac8e8d79396e3/metadata/Y3ZuPWRmMTgwMmI2Jnc9dHJ1ZQ \
> --provider-app-version 6a77a4 \
> --provider-version-branch master \
> --provider_base_url <http://host.docker.internal:8081> \
> --provider-states-setup-url <http://host.docker.internal:8081/provider-states> \
> --pact-broker-base-url <https://sh1989.pactflow.io> \
> --broker-token fake-token \
> --verbose true
No value provided for required option '--provider'
Sadly there's no deeper error stack than that. Simply adding the extra arg (
--provider pact-provider
- sorry about the poor provider name there 😓) makes that command work successfully.
b
@Sam Hogarth it’s because you gave it a pact broker base url.
Take that out.
You either give it a pact URL, OR you give it a base URL and a provider name.
Don’t do both.