googleapis / google-cloud-ruby

Google Cloud Client Library for Ruby
https://googleapis.github.io/google-cloud-ruby/
Apache License 2.0
1.36k stars 549 forks source link

The `project_id` option of `Google::Cloud::ErrorReporting.new` does not work #25862

Open Ishotihadus opened 5 months ago

Ishotihadus commented 5 months ago

The project_id option of Google::Cloud::ErrorReporting.new does not work. A project specified with gcloud auth application-default set-quota-project command is used instead of the specified project with this option.

Environment details

Code example

Preconditions:

require 'google/cloud/error_reporting'

er = Google::Cloud::ErrorReporting.new(project_id: '(another valid existing id)')
er.report_exception(StandardError.new)

# => /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/google-cloud-error_reporting-v1beta1-0.10.0/lib/google/cloud/error_reporting/v1beta1/report_errors_service/client.rb:266:in `rescue in report_error_event': 7:Error Reporting API has not been used in project ishotihadus before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/clouderrorreporting.googleapis.com/overview?project=ishotihadus then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.. debug_error_string:{UNKNOWN:Error received from peer ipv4:142.250.196.138:443 {grpc_message:"Error Reporting API has not been used in project ishotihadus before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/clouderrorreporting.googleapis.com/overview?project=ishotihadus then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", grpc_status:7, created_time:"2024-05-07T21:21:51.525359+09:00"}} (Google::Cloud::PermissionDeniedError)

Full backtrace

from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/grpc-1.63.0-arm64-darwin/src/ruby/lib/grpc/generic/active_call.rb:189:in `attach_status_results_and_complete_call'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/grpc-1.63.0-arm64-darwin/src/ruby/lib/grpc/generic/active_call.rb:383:in `request_response'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/grpc-1.63.0-arm64-darwin/src/ruby/lib/grpc/generic/client_stub.rb:174:in `block (2 levels) in request_response'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/grpc-1.63.0-arm64-darwin/src/ruby/lib/grpc/generic/interceptors.rb:170:in `intercept!'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/grpc-1.63.0-arm64-darwin/src/ruby/lib/grpc/generic/client_stub.rb:173:in `block in request_response'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/gapic-common-0.21.1/lib/gapic/grpc/service_stub/rpc_call.rb:123:in `call'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/gapic-common-0.21.1/lib/gapic/grpc/service_stub.rb:205:in `call_rpc'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/google-cloud-error_reporting-v1beta1-0.10.0/lib/google/cloud/error_reporting/v1beta1/report_errors_service/client.rb:261:in `report_error_event'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/google-cloud-error_reporting-0.43.0/lib/google/cloud/error_reporting/service.rb:82:in `report'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/google-cloud-error_reporting-0.43.0/lib/google/cloud/error_reporting/project.rb:126:in `report'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/google-cloud-error_reporting-0.43.0/lib/google/cloud/error_reporting/project.rb:163:in `report_exception'
        from (irb):7:in `<main>'
        from <internal:kernel>:187:in `loop'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/irb-1.11.0/exe/irb:9:in `<top (required)>'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/bin/irb:25:in `load'
        from /Users/ishotihadus/.rbenv/versions/3.3.1/bin/irb:25:in `<top (required)>'
Ishotihadus commented 5 months ago

P.S. Google::Cloud::Logging.new(project_id: '(another valid existing id)') seems to work perfectly