googleads / google-ads-ruby

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

Conversion Upload Service - uninitialized constant error #482

Closed rafath closed 9 months ago

rafath commented 9 months ago

Describe the bug:

Im trying to execute upload_offline_conversion. I set all needed params, have properly configured credentials and so on, during the process, I've got this error:

ruby/3.1.0/delegate.rb:91:in `method_missing': undefined method `consent_proto' for Google::Ads::GoogleAds::Factories::V6::Resources:Google::Ads::GoogleAds::VersionAlternate (NoMethodError)

I have downloaded gem google-ads-ruby and run the comamnd: sh scripts\codegen.sh then in my local app, I've pointed gem to the local path. Next error I've got:

google-ads-ruby/lib/google/ads/google_ads/v15/services/conversion_upload_service/client.rb:517:in `channel_pool': uninitialized constant Gapic::ServiceStub::ChannelPool (NameError)

Steps to Reproduce: Just execute the example from: https://github.com/googleads/google-ads-ruby/blob/75dfdea2c0dd751d76497333f1defa93ed1e6ed3/examples/remarketing/upload_offline_conversion.rb#L28

Expected behavior: it should call the Google API and send the record.

Client library version and API version: Client library version: branch 0.26 Google Ads API version: v15

Gemfile lock:

PATH
  remote: .
  specs:
    google-ads-googleads (26.0.0)
      gapic-common
      google-protobuf

GEM
  remote: https://rubygems.org/
  specs:
    activesupport (6.1.7.6)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 1.6, < 2)
      minitest (>= 5.1)
      tzinfo (~> 2.0)
      zeitwerk (~> 2.3)
    addressable (2.8.6)
      public_suffix (>= 2.0.2, < 6.0)
    akami (1.3.3)
      base64
      gyoku (>= 0.4.0)
      nokogiri
    allocation_tracer (0.6.3)
    ast (2.4.2)
    base64 (0.2.0)
    benchmark-ips (2.13.0)
    bigdecimal (3.1.6)
    builder (3.2.4)
    coderay (1.1.3)
    concurrent-ruby (1.2.3)
    diff-lcs (1.5.1)
    faraday (2.9.0)
      faraday-net_http (>= 2.0, < 3.2)
    faraday-net_http (3.1.0)
      net-http
    faraday-retry (2.2.0)
      faraday (~> 2.0)
    gapic-common (0.21.1)
      faraday (>= 1.9, < 3.a)
      faraday-retry (>= 1.0, < 3.a)
      google-protobuf (~> 3.18)
      googleapis-common-protos (>= 1.4.0, < 2.a)
      googleapis-common-protos-types (>= 1.11.0, < 2.a)
      googleauth (~> 1.9)
      grpc (~> 1.59)
    google-ads-common (1.0.3)
      google-ads-savon (~> 1.0, >= 1.0.2)
      httpclient (~> 2.7)
      httpi (~> 2.3)
      signet (~> 0.7)
    google-ads-savon (1.0.4)
      akami (~> 1.2)
      builder (~> 3.0)
      gyoku (~> 1.2)
      httpi (~> 2.3)
      nokogiri (~> 1.6)
      nori (~> 2.6)
      wasabi (~> 3.4)
    google-adwords-api (1.6.0)
      google-ads-common (~> 1.0.0)
      nori (~> 2.6)
    google-cloud-env (2.1.1)
      faraday (>= 1.0, < 3.a)
    google-protobuf (3.25.3)
    googleapis-common-protos (1.4.0)
      google-protobuf (~> 3.14)
      googleapis-common-protos-types (~> 1.2)
      grpc (~> 1.27)
    googleapis-common-protos-types (1.12.0)
      google-protobuf (~> 3.18)
    googleauth (1.11.0)
      faraday (>= 1.0, < 3.a)
      google-cloud-env (~> 2.1)
      jwt (>= 1.4, < 3.0)
      multi_json (~> 1.11)
      os (>= 0.9, < 2.0)
      signet (>= 0.16, < 2.a)
    grpc (1.61.0)
      google-protobuf (~> 3.25)
      googleapis-common-protos-types (~> 1.0)
    gyoku (1.4.0)
      builder (>= 2.1.2)
      rexml (~> 3.0)
    httpclient (2.8.3)
    httpi (2.5.0)
      rack
      socksify
    i18n (1.14.1)
      concurrent-ruby (~> 1.0)
    json (2.7.1)
    jwt (2.7.1)
    language_server-protocol (3.17.0.3)
    lint_roller (1.1.0)
    method_source (1.0.0)
    mini_portile2 (2.8.5)
    minitest (5.22.2)
    multi_json (1.15.0)
    net-http (0.4.1)
      uri
    nokogiri (1.16.2)
      mini_portile2 (~> 2.8.2)
      racc (~> 1.4)
    nori (2.7.0)
      bigdecimal
    os (1.1.4)
    parallel (1.24.0)
    parser (3.3.0.5)
      ast (~> 2.4.1)
      racc
    pry (0.14.2)
      coderay (~> 1.1)
      method_source (~> 1.0)
    public_suffix (5.0.4)
    racc (1.7.3)
    rack (3.0.9)
    rainbow (3.1.1)
    rake (13.1.0)
    regexp_parser (2.9.0)
    rexml (3.2.6)
    rspec (3.13.0)
      rspec-core (~> 3.13.0)
      rspec-expectations (~> 3.13.0)
      rspec-mocks (~> 3.13.0)
    rspec-core (3.13.0)
      rspec-support (~> 3.13.0)
    rspec-expectations (3.13.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.13.0)
    rspec-mocks (3.13.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.13.0)
    rspec-support (3.13.0)
    rubocop (1.60.2)
      json (~> 2.3)
      language_server-protocol (>= 3.17.0)
      parallel (~> 1.10)
      parser (>= 3.3.0.2)
      rainbow (>= 2.2.2, < 4.0)
      regexp_parser (>= 1.8, < 3.0)
      rexml (>= 3.2.5, < 4.0)
      rubocop-ast (>= 1.30.0, < 2.0)
      ruby-progressbar (~> 1.7)
      unicode-display_width (>= 2.4.0, < 3.0)
    rubocop-ast (1.30.0)
      parser (>= 3.2.1.0)
    rubocop-performance (1.20.2)
      rubocop (>= 1.48.1, < 2.0)
      rubocop-ast (>= 1.30.0, < 2.0)
    ruby-progressbar (1.13.0)
    signet (0.19.0)
      addressable (~> 2.8)
      faraday (>= 0.17.5, < 3.a)
      jwt (>= 1.5, < 3.0)
      multi_json (~> 1.10)
    socksify (1.7.1)
    standard (1.34.0)
      language_server-protocol (~> 3.17.0.2)
      lint_roller (~> 1.0)
      rubocop (~> 1.60)
      standard-custom (~> 1.0.0)
      standard-performance (~> 1.3)
    standard-custom (1.0.2)
      lint_roller (~> 1.0)
      rubocop (~> 1.50)
    standard-performance (1.3.1)
      lint_roller (~> 1.1)
      rubocop-performance (~> 1.20.2)
    tzinfo (2.0.6)
      concurrent-ruby (~> 1.0)
    unicode-display_width (2.5.0)
    uri (0.13.0)
    wasabi (3.7.0)
      addressable
      httpi (~> 2.0)
      nokogiri (>= 1.4.2)
    yard (0.9.34)
    zeitwerk (2.6.13)

PLATFORMS
  ruby

DEPENDENCIES
  activesupport (~> 6.1)
  allocation_tracer
  benchmark-ips
  bundler
  google-ads-googleads-rk!
  google-adwords-api (~> 1.5)
  minitest
  pry (~> 0.14.1)
  rake
  rspec (~> 3.6)
  standard
  yard

BUNDLED WITH
   2.3.26

Request/Response Logs:

Anything else we should know about your project / environment: Ruby 3.1.3

mcloonan commented 9 months ago

You should never have to run codegen yourself; that's a tool for us when we're building the gems. You could, I suppose, but you should just be using the officially released gems.

The strange part of your error message is here:

Google::Ads::GoogleAds::Factories::V6::Resources:Google::Ads::GoogleAds::VersionAlternate

That V6 is wrong; the only currently supported versions are V14 and V15. The file mentioned there is something that would be generated by the codegen, so I have to imagine something went wrong with your attempt there.

When I do these steps:

> git clone https://github.com/googleads/google-ads-ruby.git
> cd google-ads-ruby
> bundle exec rake test
> bundle exec ruby examples/basic_operations/get_campaigns.rb -C[account id]

Everything works fine. The errors you've shown above shouldn't be example-specific, so I just picked one that's easy to execute.

rafath commented 9 months ago

further investigation showed, that https://github.com/googleads/google-ads-ruby/blob/main/google-ads-googleads.gemspec#L37 is using old version of gapic-common gem (0.21.1), new version has number 0.3.4. and it does not have those modules/classes. When I use old version of gapic-common Im getting gem versions error

Bundler could not find compatible versions for gem "faraday":
  In Gemfile:
    faraday

    google-ads-googleads was resolved to 26.0.0, which depends on
      gapic-common (~> 0.20) was resolved to 0.21.1, which depends on
        faraday (>= 1.9, < 3.a)

    google-api-client (= 0.45.1) was resolved to 0.45.1, which depends on
      googleauth (~> 0.9) was resolved to 0.17.1, which depends on
        faraday (>= 0.17.3, < 2.0)

    oauth2 (= 0.6.1) was resolved to 0.6.1, which depends on
      faraday (~> 0.7)

    signet (~> 0.17) was resolved to 0.19.0, which depends on
      faraday (>= 0.17.5, < 3.a)
mcloonan commented 9 months ago

It looks like your oauth2 restriction at 0.6.1 (which is not enforced by this library) requires a version of faraday that is <1.0 (implied by the ~> 0.7 requirement), but gapic-common (which is required by this library) requires faraday of >= 1.9.

You'll have to find a way to loosen your oauth2 restrictions. The newest verison (2.0.9) does support a modern faraday version, see: https://rubygems.org/gems/oauth2

rafath commented 9 months ago

@mcloonan thank you for pointing it out <3 missed that but tbh I assumed that oauth comes from this gem too ;/.