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.63k stars 349 forks source link

[V3] Provider Verification - Crash when using consumerVersionSelectors with multiple items #776

Closed lviana-menlosecurity closed 2 years ago

lviana-menlosecurity commented 3 years ago

Software versions

Please provide at least OS and version of pact-js

Issue Checklist

Please confirm the following:

Expected behaviour

Using consumerVersionSelectors with multiple items should work.

Actual behaviour

Using consumerVersionSelectors with multiple items causes a crash.

Steps to reproduce

Using consumerVersionSelectors with a single item like shown below, works just fine:

         consumerVersionSelectors: [
            {
               tag: 'dev',
               latest: true
            }
         ]

However, if you have more than one item in the consumerVersionSelectors list, like shown below, pact crashes:

         consumerVersionSelectors: [
            {
               tag: 'dev',
               latest: true
            },
            {
               tag: 'dev_lviana_pact',
               latest: true
            }
         ]

Relevant log files

12:44:01  [2021-11-17 20:44:00.888 +0000] INFO (1486 on 386b746a640d): pact@10.0.0-beta.54: Verifying provider
12:44:01  [2021-11-17 20:44:00.894 +0000] INFO (1486 on 386b746a640d): pact@10.0.0-beta.54: debug request/response logging enabled
12:44:01  [2021-11-17 20:44:00.897 +0000] INFO (1486 on 386b746a640d): pact-core@13.3.0: Verifying Pacts.
12:44:01  [2021-11-17 20:44:00.898 +0000] INFO (1486 on 386b746a640d): pact-core@13.3.0: Verifying Pact Files
12:44:01  [2021-11-17 20:44:00.898 +0000] DEBUG (1486 on 386b746a640d): pact-core@13.3.0: Initalising native core at log level 'debug'
12:44:01  [2021-11-17 20:44:00.905 +0000] DEBUG (1486 on 386b746a640d): pact-core@13.3.0: sending arguments to FFI:
12:44:01  [2021-11-17 20:44:00.905 +0000] DEBUG (1486 on 386b746a640d): pact-core@13.3.0: --request-timeout
12:44:01  30000
12:44:01  --loglevel
12:44:01  debug
12:44:01  --state-change-url
12:44:01  http://localhost:40615/_pactSetup
12:44:01  --provider-name
12:44:01  pnr-policy
12:44:01  --port
12:44:01  40615
12:44:01  --hostname
12:44:01  localhost
12:44:01  --consumer-version-selectors
12:44:01  {"tag":"dev","latest":true}
12:44:01  --consumer-version-selectors
12:44:01  {"tag":"dev_lviana_pact","latest":true}
12:44:01  --broker-url
12:44:01  https://menloinfra.pactflow.io
12:44:01  --token
12:44:01  <token>
12:44:01  --provider-tags
12:44:01  dev_lviana_pact
12:44:01  --provider-version
12:44:01  2.83.0-dev-44-gf0f18427
12:44:01  --publish
12:44:01  [2021-11-17T20:44:00Z ERROR pact_ffi::verifier::verifier] error verifying Pact: "error: The argument '--consumer-version-selectors <consumer-version-selectors>' was provided more than once, but cannot be used multiple times\n\nUSAGE:\n    pact_verifier_cli --broker-url <broker-url> --consumer-version-selectors <consumer-version-selectors> --dir <dir>... --file <file>... --hostname <hostname> --loglevel <loglevel> --port <port> --provider-name <provider-name> --provider-tags <provider-tags> --provider-version <provider-version> --publish --request-timeout <request-timeout> --scheme <scheme> --state-change-url <state-change-url> --token <token> --url <url>...\n\nFor more information try --help" Error { message: "error: The argument '--consumer-version-selectors <consumer-version-selectors>' was provided more than once, but cannot be used multiple times\n\nUSAGE:\n    pact_verifier_cli --broker-url <broker-url> --consumer-version-selectors <consumer-version-selectors> --dir <dir>... --file <file>... --hostname <hostname> --loglevel <loglevel> --port <port> --provider-name <provider-name> --provider-tags <provider-tags> --provider-version <provider-version> --publish --request-timeout <request-timeout> --scheme <scheme> --state-change-url <state-change-url> --token <token> --url <url>...\n\nFor more information try --help", kind: UnexpectedMultipleUsage, info: Some(["consumer-version-selectors"]) }
12:44:01  [2021-11-17 20:44:00.908 +0000] DEBUG (1486 on 386b746a640d): pact-core@13.3.0: response from verifier: null, 4
12:44:01  [2021-11-17 20:44:00.908 +0000] ERROR (1486 on 386b746a640d): pact-core@13.3.0: !!!!!!!!! PACT CRASHED !!!!!!!!!
mefellows commented 3 years ago

Thanks @lviana-menlosecurity - I saw this regression also and fixed it recently in the rust core.

We need to get it into the latest node release.

mefellows commented 2 years ago

This should be fixed now, closing.