Hey, been stuck on this error for a while and can’...
# pact-js
m
Hey, been stuck on this error for a while and can’t seem to figure out the issue. Anyone have any ideas?
Copy code
[2022-10-12 04:12:55.982 +0000] INFO (7982 on MBP190F6MD6V): pact@10.1.4: Verifying provider
[2022-10-12 04:12:55.992 +0000] INFO (7982 on MBP190F6MD6V): pact-core@13.9.1: Verifying Pacts.
[2022-10-12 04:12:55.993 +0000] INFO (7982 on MBP190F6MD6V): pact-core@13.9.1: Verifying Pact Files
2022-10-12T04:12:56.799691Z  INFO ThreadId(13) pact_verifier::pact_broker: Fetching path '/' from pact broker
2022-10-12T04:12:58.135082Z  INFO ThreadId(13) pact_verifier::pact_broker: Fetching path '/pacts/provider/dummy-provider/for-verification' from pact broker
2022-10-12T04:12:59.029343Z ERROR ThreadId(13) pact_verifier: Failed to load pact - Could not load pacts from the pact broker '<https://mikeyhaven.pactflow.io>'
2022-10-12T04:12:59.029372Z  WARN ThreadId(13) pact_matching::metrics: 

Failures:

1) Failed to load pact - Could not load pacts from the pact broker '<https://mikeyhaven.pactflow.io>'


There were 1 pact failures

[2022-10-12 04:12:59.470 +0000] ERROR (7982 on MBP190F6MD6V): pact-core@13.9.1: Verification unsuccessful
FAIL dummy-app-api apps/dummy-app-api/tests/pact/provider/verify.pact.ts (5.593 s)
  Dummy Provider Pact Verification
    ✕ validates the expectations of the consumer (3489 ms)

  ● Dummy Provider Pact Verification › validates the expectations of the consumer

    Verfication failed

      at ../../node_modules/@pact-foundation/pact-core/src/verifier/nativeVerifier.ts:50:20
This is `verify.pact.ts`:
Copy code
import { Verifier } from '@pact-foundation/pact';
import { VerifierOptions } from '@pact-foundation/pact/src/dsl/verifier/types';

describe('Dummy Provider Pact Verification', () => {
    const options: VerifierOptions = {
        provider: 'dummy-provider',
        providerBaseUrl: `<http://localhost:3000>`,
        pactBrokerUrl: "<https://mikeyhaven.pactflow.io>",
        pactBrokerToken: process.env.PACT_BROKER_TOKEN,
        providerVersion: "1.0.0",
        providerVersionBranch: "feat/example-branch",
        consumerVersionSelectors: [
            { mainBranch: true, latest: true },
            { branch: 'master', latest: true },
            { tag: 'release-candidate', latest: true },
            { matchingBranch: true, latest: true },
        ],
        enablePending: true,
        includeWipPactsSince: '2022-09-01',
        publishVerificationResult: true,
    };

    const verifier = new Verifier(options);

    it('validates the expectations of the consumer', () => {
        return verifier.verifyProvider();
    });
});
Additional notes: • I’m using PactJS with a version of
v10.1.4
but I pretty much got the same error on
v10.1.0
. • I publish using V3 specification. • I’ve checked using
logLevel: DEBUG
and it doesn’t provide any other useful contextual information as to why it can’t find the pacts associated with the provider. • I even checked using
pact-broker describe-pacticipant --name dummy-provider
and it correctly shows that the broker recognizes it. • I also made sure the token is a read/write token. Below is my PactFlow:
Additional information from the consumer / publication side:
Copy code
import { PactV3 as Pact, PactV3Options as PactOptions, V3MockServer } from '@pact-foundation/pact';

const options: PactOptions = {
    dir: path.resolve(process.cwd(), 'pacts'),
    consumer: 'dummy-consumer',
    provider: 'dummy-provider',
};

const provider = new Pact(options);

...<rest of the code is just the tests which isn't important>
Publication: I’m executing this command
Copy code
pact-broker publish ./pacts/ \
    --broker-base-url="$BROKER_URL" \
    --broker-token="$BROKER_TOKEN" \
    --consumer-app-version="1.0.0" \
    --branch="feat/example-branch" \
    --tag="feat/example-branch"
m
thanks for the report and the detail! Can you please share the
DEBUG
logs? Might not be helpful to you, but definitely helpful to us
m
Sure, here they are @Matt (pactflow.io / pact-js / pact-go) :
Copy code
[2022-10-12 13:08:27.494 +0000] INFO (88817 on MBP190F6MD6V): pact@10.1.4: Verifying provider
[2022-10-12 13:08:27.500 +0000] INFO (88817 on MBP190F6MD6V): pact@10.1.4: debug request/response logging enabled
[2022-10-12 13:08:27.506 +0000] INFO (88817 on MBP190F6MD6V): pact-core@13.9.1: Verifying Pacts.
[2022-10-12 13:08:27.507 +0000] INFO (88817 on MBP190F6MD6V): pact-core@13.9.1: Verifying Pact Files
[2022-10-12 13:08:27.507 +0000] DEBUG (88817 on MBP190F6MD6V): pact-core@13.9.1: Initalising native core at log level 'debug'
[2022-10-12 13:08:27.534 +0000] DEBUG (88817 on MBP190F6MD6V): pact-core@13.9.1: the optional ffi function 'pactffiVerifierSetFilterInfo' was not executed as it had non-fatal validation errors: 
[2022-10-12 13:08:27.538 +0000] DEBUG (88817 on MBP190F6MD6V): pact-core@13.9.1: the optional ffi function 'pactffiVerifierSetConsumerFilters' was not executed as it had non-fatal validation errors: 
[2022-10-12 13:08:27.538 +0000] DEBUG (88817 on MBP190F6MD6V): pact-core@13.9.1: the optional ffi function 'pactffiVerifierAddCustomHeader' was not executed as it had non-fatal validation errors: 
[2022-10-12 13:08:27.538 +0000] DEBUG (88817 on MBP190F6MD6V): pact-core@13.9.1: the optional ffi function 'pactffiVerifierAddDirectorySource' was not executed as it had non-fatal validation errors: 
2022-10-12T13:08:27.561099Z DEBUG ThreadId(01) pact_ffi::verifier::handle: Pact source to verify = PactBrokerWithDynamicConfiguration(<https://mikeyhaven.pactflow.io>, provider_name='dummy-provider', enable_pending=true, include_wip_since=Some("2022-09-01"), provider_tags=[], provider_branch=Some("feat/example-branch"), consumer_version_selectors='[ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: Some(true), deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: Some(true), branch: None, matching_branch: None }, ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: Some(true), deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: None, branch: Some("master"), matching_branch: None }, ConsumerVersionSelector { consumer: None, tag: Some("release-candidate"), fallback_tag: None, latest: Some(true), deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: None, branch: None, matching_branch: None }, ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: Some(true), deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: None, branch: None, matching_branch: Some(true) }], auth=Token(1LS3******************)')
2022-10-12T13:08:27.572036Z DEBUG ThreadId(01) pact_plugin_driver::catalogue_manager: Updated catalogue entries:
core/content-generator/binary
core/content-generator/json
core/content-matcher/json
core/content-matcher/multipart-form-data
core/content-matcher/text
core/content-matcher/xml
2022-10-12T13:08:27.572096Z DEBUG ThreadId(01) pact_plugin_driver::catalogue_manager: Updated catalogue entries:
core/matcher/v1-equality
core/matcher/v2-max-type
core/matcher/v2-min-type
core/matcher/v2-minmax-type
core/matcher/v2-regex
core/matcher/v2-type
core/matcher/v3-content-type
core/matcher/v3-date
core/matcher/v3-datetime
core/matcher/v3-decimal-type
core/matcher/v3-includes
core/matcher/v3-integer-type
core/matcher/v3-null
core/matcher/v3-number-type
core/matcher/v3-time
core/matcher/v4-array-contains
core/matcher/v4-equals-ignore-order
core/matcher/v4-max-equals-ignore-order
core/matcher/v4-min-equals-ignore-order
core/matcher/v4-minmax-equals-ignore-order
core/matcher/v4-not-empty
core/matcher/v4-semver
2022-10-12T13:08:28.243384Z  INFO ThreadId(01) pact_verifier::pact_broker: Fetching path '/' from pact broker
2022-10-12T13:08:28.255770Z DEBUG tokio-runtime-worker hyper::client::connect::dns: resolving host="<http://mikeyhaven.pactflow.io|mikeyhaven.pactflow.io>"
2022-10-12T13:08:28.295159Z DEBUG ThreadId(01) hyper::client::connect::http: connecting to 13.238.95.102:443
2022-10-12T13:08:28.511744Z DEBUG ThreadId(01) hyper::client::connect::http: connected to 13.238.95.102:443
2022-10-12T13:08:28.950997Z DEBUG ThreadId(01) h2::client: binding client connection
2022-10-12T13:08:28.951070Z DEBUG ThreadId(01) h2::client: client connection bound
2022-10-12T13:08:28.951891Z DEBUG ThreadId(01) h2::codec::framed_write: send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384 }
2022-10-12T13:08:28.953604Z DEBUG ThreadId(01) hyper::client::pool: pooling idle connection for ("https", <http://mikeyhaven.pactflow.io|mikeyhaven.pactflow.io>)
2022-10-12T13:08:28.954581Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x0), max_concurrent_streams: 128, initial_window_size: 65536, max_frame_size: 16777215 }
2022-10-12T13:08:28.955035Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Settings { flags: (0x1: ACK) }
2022-10-12T13:08:28.955061Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=WindowUpdate { stream_id: StreamId(0), size_increment: 2147418112 }
2022-10-12T13:08:28.955369Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 }
2022-10-12T13:08:28.955410Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
2022-10-12T13:08:29.417038Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x1: ACK) }
2022-10-12T13:08:29.417062Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::proto::settings: received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384 }
2022-10-12T13:08:29.553567Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
2022-10-12T13:08:29.553902Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(1) }
2022-10-12T13:08:29.553928Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(1), flags: (0x1: END_STREAM) }
2022-10-12T13:08:29.556121Z DEBUG ThreadId(01) pact_verifier::pact_broker: Link URL is templated
2022-10-12T13:08:29.556155Z DEBUG ThreadId(01) pact_verifier::pact_broker: templated URL = <https://mikeyhaven.pactflow.io/pacts/provider/{provider}/for-verification>
2022-10-12T13:08:29.560715Z DEBUG ThreadId(01) pact_verifier::pact_broker: final URL = <https://mikeyhaven.pactflow.io/pacts/provider/dummy-provider/for-verification>
2022-10-12T13:08:29.561527Z  INFO ThreadId(01) pact_verifier::pact_broker: Fetching path '/pacts/provider/dummy-provider/for-verification' from pact broker
2022-10-12T13:08:29.561568Z DEBUG ThreadId(01) hyper::client::pool: reuse idle connection for ("https", <http://mikeyhaven.pactflow.io|mikeyhaven.pactflow.io>)
2022-10-12T13:08:29.562336Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(3), flags: (0x5: END_HEADERS | END_STREAM) }
2022-10-12T13:08:29.928715Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(3), flags: (0x4: END_HEADERS) }
2022-10-12T13:08:29.928741Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3) }
2022-10-12T13:08:29.929248Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3), flags: (0x1: END_STREAM) }
2022-10-12T13:08:29.930233Z DEBUG ThreadId(01) pact_verifier::pact_broker: templated URL = <https://mikeyhaven.pactflow.io/pacts/provider/dummy-provider/for-verification>
2022-10-12T13:08:29.930674Z DEBUG ThreadId(01) pact_verifier::pact_broker: final URL = <https://mikeyhaven.pactflow.io/pacts/provider/dummy-provider/for-verification>
2022-10-12T13:08:29.930844Z DEBUG ThreadId(01) pact_verifier::pact_broker: Sending JSON to <https://mikeyhaven.pactflow.io/pacts/provider/dummy-provider/for-verification> using POST: {"providerVersionTags":[],"includePendingStatus":true,"includeWipPactsSince":"2022-09-01","consumerVersionSelectors":[{"latest":true,"mainBranch":true},{"latest":true,"branch":"master"},{"tag":"release-candidate","latest":true},{"latest":true,"matchingBranch":true}],"providerVersionBranch":"feat/example-branch"}
2022-10-12T13:08:29.930891Z DEBUG ThreadId(01) hyper::client::pool: reuse idle connection for ("https", <http://mikeyhaven.pactflow.io|mikeyhaven.pactflow.io>)
2022-10-12T13:08:29.930991Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(5), flags: (0x4: END_HEADERS) }
2022-10-12T13:08:29.931013Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Data { stream_id: StreamId(5), flags: (0x1: END_STREAM) }
2022-10-12T13:08:30.479482Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(5), flags: (0x4: END_HEADERS) }
2022-10-12T13:08:30.479510Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(5) }
2022-10-12T13:08:30.479518Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(5), flags: (0x1: END_STREAM) }
2022-10-12T13:08:30.479609Z DEBUG ThreadId(01) pact_verifier::pact_broker: error Response for pacts for verification ContentError("Request to pact broker URL '<https://mikeyhaven.pactflow.io/pacts/provider/dummy-provider/for-verification>' failed - HTTP status client error (400 Bad Request) for url (<https://mikeyhaven.pactflow.io/pacts/provider/dummy-provider/for-verification>)") 
2022-10-12T13:08:30.479920Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }
2022-10-12T13:08:30.479936Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::proto::connection: Connection::poll; connection error error=GoAway(b"", NO_ERROR, Library)
2022-10-12T13:08:30.480710Z ERROR ThreadId(01) pact_verifier: Failed to load pact - Could not load pacts from the pact broker '<https://mikeyhaven.pactflow.io>'
2022-10-12T13:08:30.480734Z DEBUG ThreadId(01) pact_matching::metrics: 'PACT_DO_NOT_TRACK' environment variable is set, will not send metrics

Failures:

1) Failed to load pact - Could not load pacts from the pact broker '<https://mikeyhaven.pactflow.io>'


There were 1 pact failures

2022-10-12T13:08:30.481178Z DEBUG ThreadId(01) pact_plugin_driver::plugin_manager: Shutting down all plugins
[2022-10-12 13:08:30.482 +0000] DEBUG (88817 on MBP190F6MD6V): pact-core@13.9.1: shutting down verifier with handle 0
[2022-10-12 13:08:30.482 +0000] DEBUG (88817 on MBP190F6MD6V): pact-core@13.9.1: response from verifier: null, 1
[2022-10-12 13:08:30.482 +0000] ERROR (88817 on MBP190F6MD6V): pact-core@13.9.1: Verification unsuccessful
FAIL dummy-app-api apps/dummy-app-api/tests/pact/provider/verify.pact.ts (5.896 s)
  Dummy Provider Pact Verification
    ✕ validates the expectations of the consumer (2990 ms)

  ● Dummy Provider Pact Verification › validates the expectations of the consumer

    Verfication failed

      at ../../node_modules/@pact-foundation/pact-core/src/verifier/nativeVerifier.ts:50:20

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        6.127 s
Output from describe-participant:
Copy code
npx pact-broker describe-pacticipant --name dummy-provider --broker-base-url <https://mikeyhaven.pactflow.io> --broker-token <redacted>
Name: dummy-provider
Display Name: Dummy Provider
Created At: '2022-10-12T04:11:47+00:00'
m
These two lines seem to be the issue:
Copy code
2022-10-12T13:08:29.930844Z DEBUG ThreadId(01) pact_verifier::pact_broker: Sending JSON to <https://mikeyhaven.pactflow.io/pacts/provider/dummy-provider/for-verification> using POST: {"providerVersionTags":[],"includePendingStatus":true,"includeWipPactsSince":"2022-09-01","consumerVersionSelectors":[{"latest":true,"mainBranch":true},{"latest":true,"branch":"master"},{"tag":"release-candidate","latest":true},{"latest":true,"matchingBranch":true}],"providerVersionBranch":"feat/example-branch"}
...
2022-10-12T13:08:30.479609Z DEBUG ThreadId(01) pact_verifier::pact_broker: error Response for pacts for verification ContentError("Request to pact broker URL '<https://mikeyhaven.pactflow.io/pacts/provider/dummy-provider/for-verification>' failed - HTTP status client error (400 Bad Request) for url
note the
400
bad request
I think it’s the additional
latest
key
That’s only valid for tags
m
wow, that was it! thank you so much @Matt (pactflow.io / pact-js / pact-go)! Does this mean that by just specifying
branch
, it will verify the latest pact for that branch?
1
also I’m thinking I should make a ticket to track this. It would be best if we can update the typescript interfaces to disallow having incompatible options together so devs can see if they messed up their configuration from intellisense
m
That would be great if you could please raise an issue