Skip to content

fix(error_reporting): respect quota_project configuration#34610

Open
torreypayne wants to merge 13 commits into
mainfrom
fix-error-reporting-quota-project
Open

fix(error_reporting): respect quota_project configuration#34610
torreypayne wants to merge 13 commits into
mainfrom
fix-error-reporting-quota-project

Conversation

@torreypayne

@torreypayne torreypayne commented Jun 11, 2026

Copy link
Copy Markdown
Member

fix(error_reporting): respect quota_project configuration

This PR fixes an issue where the Google::Cloud::ErrorReporting client was completely ignoring the quota_project configuration parameter, causing API calls to default billing to the project associated with the credentials. This resulted in PermissionDeniedError (Error Reporting API not enabled) for users attempting to report errors to a target project that was different from their credentials project (e.g., issue #25862).

closes: #25862

Changes

  • Respect Configuration: Updated Google::Cloud::ErrorReporting.new to correctly resolve quota_project from the library configuration and pipe it down to the internal Service layer.
  • Service Wrapper: Updated Google::Cloud::ErrorReporting::Service to accept quota_project (falling back to credentials) and apply it to the underlying gRPC client configuration.
  • Documentation: Added multi-project configuration examples and descriptions to README.md and AUTHENTICATION.md.
  • Testing: Added unit test coverage to confirm configuration propagation and refined YARD doctest mock expectations.
  • Modernization: Modernized Google::Cloud::ErrorReporting::Project#report to use Ruby 3.2+ anonymous block forwarding (*args, &), resolving pre-existing RuboCop style offenses.

Expectation Setting: Target Project vs. Quota Project

In Google Cloud APIs, the Target Project (where resources are stored/written) and the Quota Project (which project is billed for the API call) are intentionally separate concepts:

  • By default, the library bills the project associated with your credentials.
  • If you need to report errors to a project that differs from your credentials project, you must explicitly configure quota_project via library configuration or the GOOGLE_CLOUD_QUOTA_PROJECT environment variable.

Configuration Example:

Google::Cloud::ErrorReporting.configure do |config|
  config.project_id    = "target-project-id"   # Where error events are ingested
  config.quota_project = "billing-project-id"  # Project billed for the quota
  config.credentials   = "path/to/keyfile.json"
end

# Client will now respect the configured quota project for billing
client = Google::Cloud::ErrorReporting.new

Torrey Payne added 2 commits June 11, 2026 18:10
Allows configuring quota_project explicitly in Google::Cloud::ErrorReporting.new
and via configuration. This resolves issues where the default quota project
from credentials is used but has the Error Reporting API disabled.
@torreypayne torreypayne marked this pull request as ready for review June 12, 2026 20:13
@torreypayne torreypayne requested review from a team and yoshi-approver as code owners June 12, 2026 20:13
@torreypayne torreypayne changed the title fix: support quota_project in ErrorReporting client fix(error_reporting): respect quota_project configuration Jun 15, 2026

@aandreassa aandreassa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! A couple nits

Comment thread google-cloud-error_reporting/lib/google/cloud/error_reporting.rb Outdated
Comment thread google-cloud-error_reporting/lib/google/cloud/error_reporting/service.rb Outdated
Comment thread google-cloud-error_reporting/support/doctest_helper.rb Outdated
Comment thread google-cloud-error_reporting/test/google/cloud/error_reporting_test.rb Outdated
@torreypayne torreypayne requested a review from aandreassa June 16, 2026 16:22

@aandreassa aandreassa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TY!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants