Add location for table in agent events in plugin BigQueryAgentAnaly… #3784
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.
…tics
Problem: The BigQueryAgentAnalyticsPlugin initializes the bigquery.Client without a specific location, causing it to default to "US".
This behavior breaks functionality for users in organizations with strict Organization Policies (constraints) that forbid creating or accessing resources in the "US" multi-region. When the plugin attempts to connect to "US", it fails due to Data Residency or Organization Policy restrictions.
Solution: I updated the _ensure_init method to pass the location=self._location argument when initializing bigquery.Client.
This allows the user to specify a compliant region (e.g., europe-west1) in the plugin constructor, ensuring the underlying client respects the location constraint and avoids policy violations.
Testing Plan
Unit Tests:
[ ] I have added or updated unit tests for my change.
[x] All unit tests pass locally.
Ran existing suite via pytest. No regressions found.
Manual End-to-End (E2E) Tests:
To verify this fix, I performed the following manual test:
Created a BigQuery Dataset in a non-US region (e.g., europe-west1).
Initialized the BigQueryAgentAnalyticsPlugin with location="europe-west1".
Verified that the plugin successfully connected and created/accessed the table without raising a "Not Found" or location error.
Checklist
[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[ ] I have commented my code, particularly in hard-to-understand areas.
[ ] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.
[x] I have manually tested my changes end-to-end.
[ ] Any dependent changes have been merged and published in downstream modules.