googleapis / googleapis/google-cloud-ruby

google-analytics-data - received '13:Internal error encountered.' when running a report, and passing an incorrect shape in the `metrics` field

Open
#19,013 1 comment 0 reactions 0 assignees View on GitHub
priority: p3 type: cleanup
Dominant language
Ruby
Stars
1.4k
Forks
578
Avg merge
1d 11h
Merged PRs (30d)
166

Description

*edit: Issue is resolved, but leaving this open because this error isn't being handed on the Google side. Original below:*

Hi,

I'm working on porting a UA integration over to v4 / data v1, and and am running into this error for a very simple request. I've traced through the gem to ensure that the auth method is valid (which it should be, as `Google::Auth::UserRefreshCredentials` is a `Signet::OAuth2::Client`). Not sure what else it could be.

#### Environment details

- OS: Ubuntu 22.04.1
- Ruby version: 3.1.0
- Gem name and version: google-analytics-data v. 0.3.1

#### Steps to reproduce

1. The included script below (when filled with accurate parameters) shows the issue

#### Code example

```ruby
client_id = 'my-client-id'
client_secret = 'my-client-secret'
access_token = 'my-access-token'
refresh_token = 'my-refresh-token'
property_id = 'my-property-id'

client = ::Google::Analytics::Data.analytics_data do |config|
config.credentials = Google::Auth::UserRefreshCredentials.new(
client_id: client_id,
client_secret: client_secret,
access_token: access_token,
refresh_token: refresh_token,
scope: 'https://www.googleapis.com/auth/analytics.readonly',
expires_at: 0
)
end

report = {
property: "properties/#{property_id}",
date_ranges: [{ start_date: '2022-08-03', end_date: '2022-08-10' }],
metrics: [{ name: 'gametric', expression: 'active28DayUsers' }],
dimensions: [{ name: 'date' }]
}

client.run_report(report)
```

#### Full backtrace

```sh
/home/mpd/.rvm/gems/ruby-3.1.0/gems/google-analytics-data-v1beta-0.5.0/lib/google/analytics/data/v1beta/analytics_data/client.rb:316:in `rescue in run_report': 13:Internal error encountered.. debug_error_string:{UNKNOWN:Error received from peer ipv6:%5B2607:f8b0:4005:802::200a%5D:443 {created_time:"2022-08-10T12:31:24.496579441-07:00", grpc_status:13, grpc_message:"Internal error encountered."}} (Google::Cloud::InternalError)
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/google-analytics-data-v1beta-0.5.0/lib/google/analytics/data/v1beta/analytics_data/client.rb:278:in `run_report'
from /home/mpd/.config/JetBrains/RubyMine2022.2/scratches/scratch_22.rb:33:in `'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/railties-7.0.2.3/lib/rails/commands/runner/runner_command.rb:43:in `perform'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/railties-7.0.2.3/lib/rails/command/base.rb:87:in `perform'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/railties-7.0.2.3/lib/rails/command.rb:48:in `invoke'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/railties-7.0.2.3/lib/rails/commands.rb:18:in `'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/mpd/git-sources/double_loop/bin/rails:4:in `'
/home/mpd/.rvm/gems/ruby-3.1.0/gems/grpc-1.48.0-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:29:in `check_status': 13:Internal error encountered.. debug_error_string:{UNKNOWN:Error received from peer ipv6:%5B2607:f8b0:4005:802::200a%5D:443 {created_time:"2022-08-10T12:31:24.496579441-07:00", grpc_status:13, grpc_message:"Internal error encountered."}} (GRPC::Internal)
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/grpc-1.48.0-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:186:in `attach_status_results_and_complete_call'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/grpc-1.48.0-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:382:in `request_response'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/grpc-1.48.0-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:174:in `block (2 levels) in request_response'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/grpc-1.48.0-x86_64-linux/src/ruby/lib/grpc/generic/interceptors.rb:170:in `intercept!'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/grpc-1.48.0-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:173:in `block in request_response'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/gapic-common-0.11.1/lib/gapic/grpc/service_stub/rpc_call.rb:121:in `call'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/gapic-common-0.11.1/lib/gapic/grpc/service_stub.rb:156:in `call_rpc'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/google-analytics-data-v1beta-0.5.0/lib/google/analytics/data/v1beta/analytics_data/client.rb:311:in `run_report'
from /home/mpd/.config/JetBrains/RubyMine2022.2/scratches/scratch_22.rb:33:in `'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/railties-7.0.2.3/lib/rails/commands/runner/runner_command.rb:43:in `perform'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/railties-7.0.2.3/lib/rails/command/base.rb:87:in `perform'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/railties-7.0.2.3/lib/rails/command.rb:48:in `invoke'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/railties-7.0.2.3/lib/rails/commands.rb:18:in `'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/mpd/.rvm/gems/ruby-3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /home/mpd/git-sources/double_loop/bin/rails:4:in `'

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.