pact-foundation / pact-ruby-cli

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

Error : NameError - uninitialized constant Pactflow::Client::ProviderContracts::Publish::OpenStruct using the latest tag #131

Closed alanmoria closed 3 months ago

alanmoria commented 3 months ago

docker run -v ${PWD}:/app -w "/app" pactfoundation/pact-cli \ pactflow publish-provider-contract \ openapi.json \ -b ${PACTFLOW_HOST} \ -k ${PACTFLOW_TOKEN} \ --provider=${HELM_VALUES_SUFFIX} \ --provider-app-version=${TAG} \ --branch=${GITHUB_REF:11} \ --content-type=application/json \ --verification-exit-code=0 \ --verification-results junit.xml \ --verification-results-content-type text/plain \ --verifier=schemathesis

Logs: f863b858ef: Pull complete 6a3c0f547760: Pull complete 4d861293a607: Pull complete a1a1d54333b0: Pull complete 9cbde94641b9: Pull complete Digest: sha256:aaabbc163438f7cac87740e2e86f6f4494c3ec09daf38bec1a61a037734a7143 Status: Downloaded newer image for pactfoundation/pact-cli:latest NameError - uninitialized constant Pactflow::Client::ProviderContracts::Publish::OpenStruct Error: Process completed with exit code 1.

alanmoria commented 3 months ago

Same command was working Friday

alanmoria commented 3 months ago

After several tests it seems that it's the latest version that's causing the problem with version 1.1.0.0 I no longer have this bug

YOU54F commented 3 months ago

Thanks for raising here, it was also raised in our slack

https://pact-foundation.slack.com/archives/C9VPNUJR2/p1715618482311699?thread_ts=1715591107.805749&cid=C9VPNUJR2

so it looks it is affecting others too

https://github.com/fastlane/fastlane/issues/21944

passing the following env var

-e RUBYOPT="-rostruct"

fixes it, temporarily for end users.

docker run -v $PWD:/home --rm -it -e PACT_BROKER_TOKEN -e PACT_BROKER_BASE_URL -e RUBYOPT="-rostruct" pactfoundation/pact-cli:latest pactflow publish-provider-contract /home/example/provider-contracts/oas.yml --provider foo --provider-app-version foo1 --content-type application/yaml 

We had to make some upgrades to the Dockerfile, as it was failing to build, as its possible this is a regression in ruby 3.2.4 as ostruct has never explicitly needed to be required.

Bit of a longer tail to fix it at source, as we build pact_broker-client gem, publish it to ruby gems, then consume it in pact-ruby-cli in another gem. Will try a patch build of the gem and pull from git

YOU54F commented 3 months ago

Should have a fix in place, ready to go out shortly

YOU54F commented 3 months ago

Release should be going out in a mo

https://github.com/pact-foundation/pact-ruby-cli/actions/runs/9067576567

had fun with our pact-dev automation users PAT token, haven't solved it for one of the triggers

https://github.com/pact-foundation/pact_broker-client/actions/runs/9067247947/job/24912980797

which should be triggering a gem-released on our docs site

https://github.com/pact-foundation/pact_broker-client/blob/master/.github/workflows/trigger_pact_docs_update.yml

but that might be a yak shave for another day

YOU54F commented 3 months ago

@alanmoria

Should be sorted now with tag 1.1.0.2

docker pull pactfoundation/pact-cli:latest

docker run -v $PWD:/home --rm -it -e PACT_BROKER_TOKEN -e PACT_BROKER_BASE_URL pactfoundation/pact-cli:latest pactflow publish-provider-contract /home/example/provider-contracts/oas.yml --provider foo --provider-app-version foo1 --content-type application/yaml            
Updated foo version foo1
  Next steps:
    Configure the version branch to be the value of your repository branch.
Provider contract republished for foo version foo1.
  View the published provider contract at https://testdemo.pactflow.io/contracts/bi-directional/provider/foo/version/foo1/provider-contract
Next steps:
  * Publish test results to show the provider correctly implements the specification.
    The can-i-deploy check for the consumer requires this. See https://docs.pactflow.io/go/publish-provider-self-verification-results
bethesque commented 3 months ago

Thanks for fixing this @YOU54F!

alanmoria commented 3 months ago

Thanks for the fix @YOU54F