Hi - I just want to check <https://docs.pact.io/im...
# pact-js
a
Hi - I just want to check https://docs.pact.io/implementation_guides/javascript/docs/provider#verification-options against experience and see if I'm driving it wrong or these are issues in the docs and the api behaviour not quite correlating. All of the following is using
@pact-foundation/pact
version
12.5.2
I'm running a local pact verification where I definitely do not want to publish verification results to the broker. When calling
new Verifier(opts).verifyProvider()
and varying the content of
opts
I get the following behaviour: 1. Neither
publishVerificationResult
nor
providerVersion
present as fields - verification proceeds smoothly with no attempt to publish 2. With
publishVerificationResult: false
but
providerVersion
absent - unexpected error because
providerVersion
not specified 3. With
publishVerificationResult: false
and
providerVersion
set to any string - verification proceeds smoothly but results are published So it feels like
publishVerificationResult: false
is not the same as omitting
publishVerificationResult
altogether, which feels slightly odd.
m
Yeah that doesn't seem right (3)
I'd need to dig in to see why that's happening. It could be in the JS library or the core
a
I went searching in the js/ts code for the place where it was figuring this out, but couldn't find it there; could it be in the ffi stuff?
m
Yeah, quite possibly
just taking a look now. The 13.x.x seems to correctly not send verification results if that flag is set to false
Downgraded to 12.5.2 and got the same result. If it’s set to true, I see:
2024-08-02T065928.136729Z INFO ThreadId(02) verify_provider_async: pact_verifier: Results published to Pact Broker
So INFO level logs should be enough to show what’s happening - mind sharing those please?
a
Thanks for looking into this; you've got me thinking I've made some silly mistake in my code 🙂 now, but I'll rerun and post the logs here when I get back to the keyboard in an hour or so.
OK I started with this scenario, which is not quite the "why is it publishing when I asked it not to", and may be unrelated, but essentially I have specified
publishVerificationResult: false
which then triggers a validation error because I haven't specified
providerVersion
. This could just be a fault in the validation logic, but I thought it was worth including as maybe its an indicator of the original problem. this is the first run, with verifier options:
Copy code
{
  "providerBaseUrl": "<http://localhost:58487>",
  "providerVersionTags": [],
  "publishVerificationResult": false,
  "providerBranch": "erewhon",
  "logLevel": "info",
  "pactBrokerUrl": "https://...",
  "provider": "nonesuch",
  "consumerVersionSelectors": [
    {
      "consumer": "foo",
      "branch": "develop",
      "latest": true
    }
  ]
}
which leads to the following validation error:
Copy code
[09:22:38.165] INFO (26976): pact@12.5.2: Verifying provider
[09:22:38.183] INFO (26976): pact-core@14.3.8: Verifying Pacts.
[09:22:38.186] ERROR (26976): publishVerificationResult requires the following properties: providerVersion

Error: publishVerificationResult requires the following properties: providerVersion
    at logErrorAndThrow (node_modules\@pact-foundation\pact-core\src\logger\index.ts:50:9)
    at C:\Dev\git_repos\daisy_uprev\node_modules\@pact-foundation\pact-core\src\verifier\validateOptions.ts:53:23
    at C:\Dev\git_repos\daisy_uprev\node_modules\@pact-foundation\pact-core\src\verifier\validateOptions.ts:273:22
    at Array.forEach (<anonymous>)
    at C:\Dev\git_repos\daisy_uprev\node_modules\@pact-foundation\pact-core\src\verifier\validateOptions.ts:272:21
    at Array.forEach (<anonymous>)
    at validateOptions (node_modules\@pact-foundation\pact-core\src\verifier\validateOptions.ts:260:5)
    at new Verifier (node_modules\@pact-foundation\pact-core\src\verifier\index.ts:16:35)
    at exports.default (node_modules\@pact-foundation\pact-core\src\verifier\index.ts:30:56)
    at Pact.verifyPacts (node_modules\@pact-foundation\pact-core\src\pact.ts:158:27)
    at C:\Dev\git_repos\daisy_uprev\node_modules\@pact-foundation\src\dsl\verifier\verifier.ts:137:29
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Second run, adding in
providerVersion
to get past the validation error. Verifier opts:
Copy code
{
  "providerBaseUrl": "<http://localhost:60429>",
  "providerVersionTags": [
    "wibble"
  ],
  "logLevel": "info",
  "publishVerificationResult": false,
  "providerVersion": "1.2.3",
  "pactBrokerUrl": "https://...",
  "provider": "nonesuch",
  "consumerVersionSelectors": [
    {
      "consumer": "foo",
      "branch": "develop",
      "latest": true
    }
  ],
  "providerVersionBranch": "wibble"
}
output logs (truncated but if you need more let me know):
Copy code
[09:46:00.179] INFO (15764): pact@12.5.2: Verifying provider
[09:46:00.199] INFO (15764): pact-core@14.3.8: Verifying Pacts.
[09:46:00.201] INFO (15764): pact-core@14.3.8: Verifying Pact Files
[09:46:00.215] INFO (15764): 0.4.20: pact native library successfully found, and the correct version

...
2024-08-02T08:46:00.948007Z  INFO ThreadId(09) pact_verifier: Running teardown provider state change handler 'me' for 'a request for me'
2024-08-02T08:46:00.962716Z  INFO ThreadId(09) pact_verifier: Publishing verification results back to the Pact Broker
2024-08-02T08:46:00.978726Z  INFO ThreadId(09) pact_verifier::pact_broker: Fetching path '/pacticipants/nonesuch' from pact broker
2024-08-02T08:46:01.128692Z  INFO ThreadId(09) pact_verifier::pact_broker: Fetching path '/pacticipants/nonesuch' from pact broker
2024-08-02T08:46:01.339507Z  INFO ThreadId(09) pact_verifier: Results published to Pact Broker
m
Thanks! That is a validation logic error I think. I wonder, you don't happen to have any Pact environment variables set do you? E.g.
PACT_
a
I did have a few environment variables set that began
PACT_
, but I tried removing those in the first of the two scenarios and it made no difference.
👍 1
🤔 1