pact-foundation / pact_broker-client

A Ruby and CLI client for the Pact Broker. Publish and retrieve pacts and verification results.
MIT License
69 stars 47 forks source link

fix: openstruct broken unless explicit require of ostruct #155

Closed YOU54F closed 6 months ago

YOU54F commented 6 months ago

So as of the latest release of pact-ruby-cli, we had some errors reported

NameError - uninitialized constant Pactflow::Client::ProviderContracts::Publish::OpenStruct

https://github.com/pact-foundation/pact-ruby-cli/issues/131

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 

Interesting, re-running our CI today, with no code changes other than adding in ruby 3.3 to the matrix, resulted in the same test failures.

https://github.com/pact-foundation/pact_broker-client/actions/runs/9066772247/job/24910431506

across Ruby 2.7 - Ruby 3.3

I wondered if it was because there was a new release of Rubies, on 2024-04-23 but that was only for Ruby 3.0.x and upwards, where we see failures today on Ruby 2.7, which we did not see 3 months ago.

Explicitly requiring 'ostruct' has resolved the test failures, but hasn't aided in reducing my confusion as to how this has suddenly manifested!

edit: to further muddy the water, I was able to successfully run the tests on my mac with ruby 3.2.4 without these changes 😅 (it also passes after) 🤷🏾‍♂️

bethesque commented 6 months ago

I have absolutely no idea! The require clearly should have been there. It is a mystery to me why it ever worked.