pact-foundation / pact-ruby-cli

Amalgamated Pact Ruby CLI
https://pact.io
MIT License
12 stars 15 forks source link

pact-cli version 0.50.0.26 throws URI error #64

Closed GaboDimitrov closed 2 years ago

GaboDimitrov commented 2 years ago

We are using pact CLI to verify our contracts for quite some time. We are using CircleCI where we always get the latest docker image for pact-cli. Since the latest version (0.50.0.26), we receive an error (check error 1). We tried to use an older version of pact-cli and we got a different error (check Error 2). We have always worked with the same value format and we even tried to execute it manually, but with no success. Can you please check what is going on, or if we miss something?

We are using this command.

            export PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true
            export PACT_BROKER_APPLICATION_TOKEN="x-api-key:$TF_VAR_x_api_key"
            pact-provider-verifier --custom-provider-header="$PACT_BROKER_APPLICATION_TOKEN" \
            --provider=$PACT_BROKER_PROVIDER_NAME \
            --provider-base-url=$PACT_BROKER_APPLICATION_URL \
            --pact-broker-base-url=$PACT_BROKER_URL --broker-token=$PACT_BROKER_TOKEN \
            --provider-version-tag=dev \
            --consumer-version-tag=dev \
            --provider-app-version=$Appversion
ERROR 1

Traceback (most recent call last):
    23: from /usr/bin/pact-provider-verifier:25:in `<main>'
    22: from /usr/bin/pact-provider-verifier:25:in `load'
    21: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/bin/pact-provider-verifier:3:in `<top (required)>'
    20: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/cli/******_thor.rb:17:in `start'
    19: from /usr/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
    18: from /usr/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    17: from /usr/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    16: from /usr/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    15: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/cli/verify.rb:49:in `verify'
    14: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/app.rb:35:in `call'
    13: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/app.rb:40:in `call'
    12: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/app.rb:225:in `warn_empty_pact_set'
    11: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/app.rb:211:in `all_pact_urls'
    10: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:10:in `call'
     9: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:26:in `call'
     8: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:39:in `pacts_urls_from_broker'
     7: from /usr/lib/ruby/gems/2.7.0/gems/pact-provider-verifier-1.36.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:46:in `pacts_for_verification'
     6: from /usr/lib/ruby/gems/2.7.0/gems/pact-1.62.0/lib/pact/pact_broker.rb:18:in `fetch_pact_uris_for_verification'
     5: from /usr/lib/ruby/gems/2.7.0/gems/pact-1.62.0/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:38:in `call'
     4: from /usr/lib/ruby/gems/2.7.0/gems/pact-1.62.0/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:42:in `call'
     3: from /usr/lib/ruby/gems/2.7.0/gems/pact-1.62.0/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:57:in `index'
     2: from /usr/lib/ruby/gems/2.7.0/gems/pact-1.62.0/lib/pact/hal/link.rb:49:in `get'
     1: from /usr/lib/ruby/gems/2.7.0/gems/pact-1.62.0/lib/pact/hal/http_client.rb:25:in `get'
/usr/lib/ruby/gems/2.7.0/gems/pact-1.62.0/lib/pact/hal/http_client.rb:39:in `create_request': undefined method `request_uri' for #<URI::Generic ********************************> (NoMethodError)
ERROR 2
Traceback (most recent call last):
    23: from /Users/gdimitrov/.gem/ruby/2.7.2/bin/pact-provider-verifier:23:in `<main>'
    22: from /Users/gdimitrov/.gem/ruby/2.7.2/bin/pact-provider-verifier:23:in `load'
    21: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/bin/pact-provider-verifier:3:in `<top (required)>'
    20: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/cli/custom_thor.rb:17:in `start'
    19: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
    18: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
    17: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
    16: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
    15: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/cli/verify.rb:48:in `verify'
    14: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/app.rb:34:in `call'
    13: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/app.rb:39:in `call'
    12: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/app.rb:219:in `warn_empty_pact_set'
    11: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/app.rb:206:in `all_pact_urls'
    10: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:10:in `call'
     9: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:25:in `call'
     8: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:38:in `pacts_urls_from_broker'
     7: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-provider-verifier-1.35.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:45:in `pacts_for_verification'
     6: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-1.62.0/lib/pact/pact_broker.rb:18:in `fetch_pact_uris_for_verification'
     5: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-1.62.0/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:38:in `call'
     4: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-1.62.0/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:42:in `call'
     3: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-1.62.0/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:57:in `index'
     2: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-1.62.0/lib/pact/hal/link.rb:49:in `get'
     1: from /Users/gdimitrov/.gem/ruby/2.7.2/gems/pact-1.62.0/lib/pact/hal/http_client.rb:20:in `get'
/Users/gdimitrov/.rubies/ruby-2.7.2/lib/ruby/2.7.0/uri/common.rb:739:in `URI': bad argument (expected URI object or URI string) (ArgumentError)
bethesque commented 2 years ago

Are you missing the https:// on the start of your Pact Broker base URL?

$ irb
irb(main):001:0> URI("foo").request_uri
Traceback (most recent call last):
        4: from /Users/bethanyskurrie/.rubies/ruby-2.7.5/bin/irb:23:in `<main>'
        3: from /Users/bethanyskurrie/.rubies/ruby-2.7.5/bin/irb:23:in `load'
        2: from /Users/bethanyskurrie/.rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        1: from (irb):1
NoMethodError (undefined method `request_uri' for #<URI::Generic foo>)

irb(main):002:0> URI("https://foo").request_uri
=> "/"
GaboDimitrov commented 2 years ago

@bethesque No, Https isn't missing.

YOU54F commented 2 years ago

Are you able to pin previous version to specific tags to ascertain which version this is affecting please?

https://hub.docker.com/r/pactfoundation/pact-cli/tags

This one specifically is 2 months old 0.50.0.21

https://hub.docker.com/layers/pact-cli/pactfoundation/pact-cli/0.50.0.21/images/sha256-eceffcaacb4069294f52ac6bc3f9b9fe69555d432557a7db365c38cfa159d436?context=explore

Using latest in CI builds for docker images has the potential to introduce to any number of breaking changes, especially if that is used across the board, rather than being an outlier

YOU54F commented 2 years ago

Also with regards to Error 1 and Error 2, which versions were these with, it isn't clear in your original report

bethesque commented 2 years ago

I've tried to replicate it using the demo code from the cli repo, and I can't reproduce it. Can you see if you can modify the example to reproduce your issue?

https://github.com/pact-foundation/pact-ruby-cli/#verify-pacts

export PACT_BROKER_BASE_URL="https://test.pactflow.io"
export PACT_BROKER_USERNAME="dXfltyFMgNOFZAxr8io9wJ37iUpY42M"
export PACT_BROKER_PASSWORD="O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1"
PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true GIT_COMMIT=fake-git-sha-for-demo$(date +%s) GIT_BRANCH=master \
  docker-compose -f docker-compose-verify.yml \
  up --build --abort-on-container-exit --exit-code-from pact_verifier
bethesque commented 2 years ago

If you can add --verbose to the verify call that will also help.

GaboDimitrov commented 2 years ago

@bethesque I tried with the demo code from your repo and it did the work. Thank you!