Repository navigation
Conversation
Collaborator
|
Hi @shaun0927 , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix formatting errors by running autoformat.sh |
Both integration helpers advertised an auth_token constructor path, but the implementation instantiated google.auth.credentials.Credentials directly. That base class is abstract, so callers hit a TypeError before any request could be made. This patch switches both helpers to a concrete OAuth2 Credentials object and adds regression coverage that exercises the real constructor path. The SecretManager helper also now rejects service_account_json + auth_token up front so its behavior matches its own documented contract. Constraint: Keep the change narrow to the validated auth helper regressions Rejected: Leave the existing mocked constructor tests in place | they masked the real runtime failure Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep token-path tests using the real credentials class so abstract-constructor regressions do not reappear Tested: .venv/bin/pytest tests/unittests/integrations/secret_manager/test_secret_client.py tests/unittests/integrations/parameter_manager/test_parameter_client.py -q Not-tested: Full repo test suite; lint tooling was not installed in the local venv
shaun0927
force-pushed
the
fix/token-credentials-for-integrations
branch
from
April 22, 2026 17:29
2aeb222 to
f91cb17
Compare
Contributor
Author
|
@rohityan @surajksharma07 Thanks for the reviews. I've rebased onto PTAL when you get a chance. |
Collaborator
|
Hi @GWeale , can you please review this. |
GWeale
approved these changes
Jun 10, 2026
copybara-service Bot
pushed a commit
that referenced
this pull request
Jun 29, 2026
…er clients Merge #5371 **Please ensure you have read the [contribution guide](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) before creating a pull request.** ### Link to Issue or Description of Change **1. Link to an existing issue (if applicable):** - Closes: #5370 **2. Or, if no issue exists, describe the change:** **Problem:** Both `SecretManagerClient` and `ParameterManagerClient` advertise an `auth_token` constructor path, but the implementation instantiates `google.auth.credentials.Credentials(...)` directly. That base class is abstract, so callers hit a `TypeError` before the underlying Google Cloud client is constructed. `SecretManagerClient` also documents that `service_account_json` and `auth_token` are mutually exclusive, but the current implementation silently accepts both inputs and ignores the token. **Solution:** - Switch both helpers to `google.oauth2.credentials.Credentials(token=auth_token)` for the `auth_token` path. - Keep the change narrow to the validated runtime regression and its adjacent contract mismatch. - Replace the mocked-constructor token-path tests with regression coverage that exercises the real credentials constructor path. - Add a `SecretManagerClient` test that confirms conflicting credential inputs raise `ValueError`. ### Testing Plan **Unit Tests:** - [x] I have added or updated unit tests for my change. - [x] All unit tests pass locally. Passed locally: ```text .venv/bin/pytest tests/unittests/integrations/secret_manager/test_secret_client.py tests/unittests/integrations/parameter_manager/test_parameter_client.py -q 17 passed, 1 warning in 24.43s ``` **Manual End-to-End (E2E) Tests:** I also re-ran the original local reproductions with patched cloud clients to confirm the behavior change: ```python from unittest.mock import MagicMock, patch from google.adk.integrations.secret_manager.secret_client import SecretManagerClient from google.adk.integrations.parameter_manager.parameter_client import ParameterManagerClient with patch("google.cloud.secretmanager.SecretManagerServiceClient", return_value=MagicMock()): client = SecretManagerClient(auth_token="test-token") assert client._credentials.token == "test-token" with patch("google.cloud.parametermanager_v1.ParameterManagerClient", return_value=MagicMock()): client = ParameterManagerClient(auth_token="test-token") assert client._credentials.token == "test-token" ``` And for the conflicting-input case: ```python import json from google.adk.integrations.secret_manager.secret_client import SecretManagerClient try: SecretManagerClient( service_account_json=json.dumps({"type": "service_account"}), auth_token="test-token", ) except ValueError: pass else: raise AssertionError("Expected conflicting credentials to raise ValueError") ``` ### Checklist - [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [x] I have performed a self-review of my own code. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] 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. - [x] Any dependent changes have been merged and published in downstream modules. ### Additional context I intentionally kept this PR focused on the reproducible auth helper regressions that are still present in the latest stable release and current `main`. Co-authored-by: Haran Rajkumar <haranrk@google.com> COPYBARA_INTEGRATE_REVIEW=#5371 from shaun0927:fix/token-credentials-for-integrations 3567a25 PiperOrigin-RevId: 939989046
Collaborator
|
Thank you @shaun0927 for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit 46a2181. Closing this PR as the changes are now in the main branch. |
FrigaZzz
pushed a commit
to FrigaZzz/adk-python
that referenced
this pull request
Aug 11, 2026
…er clients Merge google#5371 **Please ensure you have read the [contribution guide](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) before creating a pull request.** ### Link to Issue or Description of Change **1. Link to an existing issue (if applicable):** - Closes: google#5370 **2. Or, if no issue exists, describe the change:** **Problem:** Both `SecretManagerClient` and `ParameterManagerClient` advertise an `auth_token` constructor path, but the implementation instantiates `google.auth.credentials.Credentials(...)` directly. That base class is abstract, so callers hit a `TypeError` before the underlying Google Cloud client is constructed. `SecretManagerClient` also documents that `service_account_json` and `auth_token` are mutually exclusive, but the current implementation silently accepts both inputs and ignores the token. **Solution:** - Switch both helpers to `google.oauth2.credentials.Credentials(token=auth_token)` for the `auth_token` path. - Keep the change narrow to the validated runtime regression and its adjacent contract mismatch. - Replace the mocked-constructor token-path tests with regression coverage that exercises the real credentials constructor path. - Add a `SecretManagerClient` test that confirms conflicting credential inputs raise `ValueError`. ### Testing Plan **Unit Tests:** - [x] I have added or updated unit tests for my change. - [x] All unit tests pass locally. Passed locally: ```text .venv/bin/pytest tests/unittests/integrations/secret_manager/test_secret_client.py tests/unittests/integrations/parameter_manager/test_parameter_client.py -q 17 passed, 1 warning in 24.43s ``` **Manual End-to-End (E2E) Tests:** I also re-ran the original local reproductions with patched cloud clients to confirm the behavior change: ```python from unittest.mock import MagicMock, patch from google.adk.integrations.secret_manager.secret_client import SecretManagerClient from google.adk.integrations.parameter_manager.parameter_client import ParameterManagerClient with patch("google.cloud.secretmanager.SecretManagerServiceClient", return_value=MagicMock()): client = SecretManagerClient(auth_token="test-token") assert client._credentials.token == "test-token" with patch("google.cloud.parametermanager_v1.ParameterManagerClient", return_value=MagicMock()): client = ParameterManagerClient(auth_token="test-token") assert client._credentials.token == "test-token" ``` And for the conflicting-input case: ```python import json from google.adk.integrations.secret_manager.secret_client import SecretManagerClient try: SecretManagerClient( service_account_json=json.dumps({"type": "service_account"}), auth_token="test-token", ) except ValueError: pass else: raise AssertionError("Expected conflicting credentials to raise ValueError") ``` ### Checklist - [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [x] I have performed a self-review of my own code. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] 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. - [x] Any dependent changes have been merged and published in downstream modules. ### Additional context I intentionally kept this PR focused on the reproducible auth helper regressions that are still present in the latest stable release and current `main`. Co-authored-by: Haran Rajkumar <haranrk@google.com> COPYBARA_INTEGRATE_REVIEW=google#5371 from shaun0927:fix/token-credentials-for-integrations 3567a25 PiperOrigin-RevId: 939989046
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
Both
SecretManagerClientandParameterManagerClientadvertise anauth_tokenconstructor path, but the implementation instantiatesgoogle.auth.credentials.Credentials(...)directly. That base class is abstract, so callers hit aTypeErrorbefore the underlying Google Cloud client is constructed.SecretManagerClientalso documents thatservice_account_jsonandauth_tokenare mutually exclusive, but the current implementation silently accepts both inputs and ignores the token.Solution:
google.oauth2.credentials.Credentials(token=auth_token)for theauth_tokenpath.SecretManagerClienttest that confirms conflicting credential inputs raiseValueError.Testing Plan
Unit Tests:
Passed locally:
Manual End-to-End (E2E) Tests:
I also re-ran the original local reproductions with patched cloud clients to confirm the behavior change:
And for the conflicting-input case:
Checklist
Additional context
I intentionally kept this PR focused on the reproducible auth helper regressions that are still present in the latest stable release and current
main.