pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.61k stars 344 forks source link

Webhook build - publish verification results - 404 #960

Closed ColdFire87 closed 1 year ago

ColdFire87 commented 1 year ago

Software versions

Please provide at least OS and version of pact-js

Issue Checklist

Please confirm the following:

Expected behaviour

When a verification build is triggered on the provider (from the Pactflow webhook), once the pact is successfully retrieved and verified, the verifier should be able to publish the verification results back to Pactflow.

Actual behaviour

2022-10-06T12:05:42.691456Z ERROR ThreadId(20) pact_verifier: Publishing of verification results failed with an error: Link/Resource was not found - Request to pact broker path '/pacticipants/CardService' failed: 404 Not Found. URL: 'https://fundingcircle.pactflow.io/pacts/provider/CardService/consumer/CardMFE/pact-version/6e2e8fd85ed60b72906b87f3fba6769e30f3e329/metadata/Y3ZuPThjNGQyODIxYzA3MWFhZWZjZjViOThjN2Q3ZWM4NTk1NTY3ZDNjMTImdz10cnVl'

Virtual high fives

I can grant you access to the private repos at:

I can't grant you access to CI though. You should probably have access to my Pactflow account from your side.

Steps to reproduce

  1. Trigger a build on the consumer side, which generates & publishes the pact to Pactflow. image image image

  2. Webhook is configured to trigger provider build image

  3. Provider verification build runs successfully but fails to publish verification results image

  4. The version in the link (that errors with 404) is nowhere to be found in the git commit history image

It should be 8c4d2821c071aaefcf5b98c7d7ec8595567d3c12 but for some strange reason it is 6e2e8fd85ed60b72906b87f3fba6769e30f3e329 instead.

  1. Looking at the webhook logs, it appears this link is sent to the provider as PACT_URL (which is used by pactUrls field in the verifier config): https://fundingcircle.pactflow.io/pacts/provider/CardService/consumer/CardMFE/pact-version/6e2e8fd85ed60b72906b87f3fba6769e30f3e329/metadata/Y3ZuPThjNGQyODIxYzA3MWFhZWZjZjViOThjN2Q3ZWM4NTk1NTY3ZDNjMTImdz10cnVl

It appears that Pacflow is sending a wrong version number in PACT_URL (via ${pactbroker.pactUrl} in the webhook URL config).

This might be a duplicate of https://github.com/pact-foundation/pact-net/issues/417

Relevant log files

I have attached the logs for the verification webhook build. logs_FundingCircle_stefan-cdct-mvp-backend-provider_104_1_3.log

NOTE: it is a newer build (as I didn't have log level set to debug, but the same concept applies). The consumer version is 8c4d2821c071aaefcf5b98c7d7ec8595567d3c12, however PACT_URL contains a d667875b266a93e3b66cf3dba3609293bedce295 version, which doesn't correspond to any git commit sha in my git history (both across consumer & provider).

bethesque commented 1 year ago

The version in the URL is the pact version, not the consumer version sha. The issue is that there is a bug when publishing the verification results. It seems to be the same as https://github.com/pact-foundation/pact-net/issues/417

Is the ffi up to date? (question for the maintainers, not you Stefan)

bethesque commented 1 year ago

Can you check what version of pact-js-core is installed? 13.9.1 is the latest, and it has 0.3.12 of the ffi library.

ColdFire87 commented 1 year ago

I can see @pact-foundation/pact-core 13.8.0 on both the consumer & the provider. I will upgrade to 13.9.1 and give it a go.

ColdFire87 commented 1 year ago

After upgrading to 13.9.1 the verification results are now published successfully to Pactflow. Thanks!