fix(error_reporting): respect quota_project configuration#34610
Open
torreypayne wants to merge 9 commits into
Open
fix(error_reporting): respect quota_project configuration#34610torreypayne wants to merge 9 commits into
torreypayne wants to merge 9 commits into
Conversation
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.
added 6 commits
June 12, 2026 20:15
aandreassa
requested changes
Jun 16, 2026
aandreassa
left a comment
Contributor
There was a problem hiding this comment.
Looks great! A couple nits
| scope ||= configure.scope | ||
| timeout ||= configure.timeout | ||
| endpoint ||= configure.endpoint | ||
| quota_project = configure.quota_project |
Contributor
There was a problem hiding this comment.
Maybe move this line down and just use left alignment? It looks a bit off here since others are part of the parameter list.
| @credentials = credentials | ||
| @timeout = timeout | ||
| @host = host | ||
| @quota_project = quota_project || (credentials.quota_project_id if credentials.respond_to? :quota_project_id) |
Contributor
There was a problem hiding this comment.
Slightly more idiomatic to split the steps:
@quota_project = quota_project
@quota_project ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
| doctest.before "Google::Cloud#error_reporting" do | ||
| mock_error_reporting do |mock| | ||
| mock.expect :report_error_event, nil, [Hash] | ||
| mock.expect :report_error_event, nil, [], project_name: Object, event: Object |
Contributor
There was a problem hiding this comment.
Could these be something else, such as String for project_name? You may be able to grab the specific type for event as well.
| _(error_reporting).must_be_kind_of Google::Cloud::ErrorReporting::Project | ||
| end | ||
| end | ||
| Google::Cloud::ErrorReporting.configure.reset! |
Contributor
There was a problem hiding this comment.
My hesitation here is this config not being isolated. I assume if the step above fails, then the config could leak into other tests. Should it have an after block instead like others?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where the
Google::Cloud::ErrorReportingclient was ignoring thequota_projectconfiguration parameter, causing API calls to default billing to the project associated with the credentials. This resulted inPermissionDeniedError(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
Google::Cloud::ErrorReporting.newto resolvequota_projectfrom the library configuration and pass it down to the internalServicelayer.Google::Cloud::ErrorReporting::Serviceto acceptquota_projectand apply it to the underlying gRPC client configuration.quota_projectusage inREADME.mdandAUTHENTICATION.md.Expectation Setting on 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:
quota_projectvia library configuration or theGOOGLE_CLOUD_QUOTA_PROJECTenvironment variable.How to configure:
=====
Manual testing logs: