googleads / google-ads-ruby

Google Ads API Ruby Client Library
https://developers.google.com/google-ads/api/
Apache License 2.0
70 stars 67 forks source link

Calling client.service.offline_user_data_job results in `NameError: uninitialized constant Gapic::ServiceStub::ChannelPool` #464

Closed waynew111 closed 10 months ago

waynew111 commented 10 months ago

Describe the bug: Calling client.service.offline_user_data_job results in NameError: uninitialized constant Gapic::ServiceStub::ChannelPool

Steps to Reproduce:

def self.get_client
    Google::Ads::GoogleAds::GoogleAdsClient.new do |c|
        config.client_id = <client_id>
        config.client_secret = <client_secret>
        config.developer_token = <developer_token>
        config.refresh_token = <refresh_token>
    end
end

client = get_client
offline_user_data_service = client.service.offline_user_data_job

Expected behavior: Return a new instance of offline_user_data_job

Client library version and API version: Client library version: 25.0.0 Google Ads API version: v15

Gemfile.lock gems/dependencies:

google-ads-googleads (25.0.0)
google-protobuf (3.23.4)
google-protobuf (3.23.4-aarch64-linux)
googleapis-common-protos-types (1.9.0)
    google-protobuf (~> 3.18)
grpc (1.58.0)
    google-protobuf (~> 3.23)

Request/Response Logs: NameError: uninitialized constant Gapic::ServiceStub::ChannelPool /home/vagrant/.rvm/gems/ruby-2.6.3@automator/gems/google-ads-googleads-25.0.0/lib/google/ads/google_ads/v15/services/offline_user_data_job_service/operations.rb:721:in channel_pool' /home/vagrant/.rvm/gems/ruby-2.6.3@automator/gems/google-ads-googleads-25.0.0/lib/google/ads/google_ads/v15/services/offline_user_data_job_service/operations.rb:98:ininitialize' /home/vagrant/.rvm/gems/ruby-2.6.3@automator/gems/google-ads-googleads-25.0.0/lib/google/ads/google_ads/v15/services/offline_user_data_job_service/client.rb:135:in new' /home/vagrant/.rvm/gems/ruby-2.6.3@automator/gems/google-ads-googleads-25.0.0/lib/google/ads/google_ads/v15/services/offline_user_data_job_service/client.rb:135:ininitialize' /home/vagrant/.rvm/gems/ruby-2.6.3@automator/gems/google-ads-googleads-25.0.0/lib/google/ads/google_ads/factories/v15/services.rb:1966:in new' /home/vagrant/.rvm/gems/ruby-2.6.3@automator/gems/google-ads-googleads-25.0.0/lib/google/ads/google_ads/factories/v15/services.rb:1966:inoffline_user_data_job'

Anything else we should know about your project / environment: The exact same code snippet provided above works perfectly when using v13 / client library 22.0, as well as v14 / client library 24.0. It only fails for v15 / client library 25.0.

beatbull commented 10 months ago

Hi,

just by changing the google-ads-googleads gem version to 25.0.0, I got the same error as reported above, for any Ruby version I tried (3.2.1, 2.7.8). Since the issue is with gapic, I tried upgrading gapic-common to the latest version (0.20.0). This made the error disappear and the googleads gem in version 25.0.0 started working.

I think the issue is in https://github.com/googleads/google-ads-ruby/blob/main/google-ads-googleads.gemspec#L37 , the version needs to be adjusted for gapic-common in the gemspec, since the googleads gem in version 25.0.0 relies on the new channel pooling feature added in gapic-common 0.20.0, see https://github.com/googleapis/gapic-generator-ruby/releases/tag/gapic-common%2Fv0.20.0 .

Until the gemspec gets fixed, simply add following line in your local Gemfile and run bundle:

gem 'gapic-common', '~> 0.20'
waynew111 commented 10 months ago

^ ^ Thanks for figuring out the cause! I tried the above and things started working.

However, this seems to require googleauth 1.0.0. Our code base also uses google_drive 3.0.7, which requires googleauth < 1.0.0. I'm assuming even when gemspec gets fixed, this conflict would still remain. Does anybody know?

danielfrg commented 10 months ago

Thank you for the report. I tested older versions of gapic-common and confirmed that we need >0.20. It will be fixed with https://github.com/googleads/google-ads-ruby/pull/469

I will make a release once thats merged.

danielfrg commented 10 months ago

Version 25.0.1 has been released to include the fix.

waynew111 commented 10 months ago

Amazing! Thanks so much @danielfrg!

waynew111 commented 9 months ago

For anyone tracking this issue, 25.0.2 was released today to address a dependency issue in 25.0.1. Things are working on my end now.