fix(auth): handle missing client-credentials scopes safely#5348
Open
sqsge wants to merge 2 commits intogoogle:mainfrom
Open
fix(auth): handle missing client-credentials scopes safely#5348sqsge wants to merge 2 commits intogoogle:mainfrom
sqsge wants to merge 2 commits intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
|
Hello @sqsge, thank you for your contribution! It looks like the CLA (Contributor License Agreement) check has failed. Please make sure you have signed the CLA to proceed with the review process. You can find more information at https://cla.developers.google.com/. Response from ADK Triaging Agent |
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):
Problem:
The current OAuth client-credentials / M2M path can crash when
scopesis absent or collapses toNone, because bothauth_handler.pyandoauth2_credential_util.pystill assume the value is always dict-like and call.keys()on it.This shows up in the OpenAPI Toolkit client-credentials flow as:
AttributeError: 'NoneType' object has no attribute 'keys'
Solution:
Keep the fix intentionally narrow by normalizing OAuth scope handling in the two current call sites that make the dict-like assumption:
auth_handler.pyoauth2_credential_util.pyThis fix only addresses the immediate None-safe handling for the current client-credentials path. It does not attempt to redesign the broader OAuth flow semantics in this PR.
Testing Plan
Unit Tests:
Passed locally:
PYTHONPATH=src python3 -m pytest -q tests/unittests/auth/test_auth_handler.py
24 passed, 43 warnings in 2.10s
PYTHONPATH=src python3 -m pytest -q tests/unittests/auth/test_oauth2_credential_util.py
10 passed, 11 warnings in 2.08s
Manual End-to-End (E2E) Tests:
Not run for this change.
This patch is scoped to None-safe handling for the existing client-credentials code path and adds focused regression coverage for the affected auth helper paths. I did not run a manual OpenAPI Toolkit end-to-end flow locally in this branch.
Checklist
Additional context
This PR keeps the change small on purpose:
scopes.keys()assumption in the current client-credentials/M2M path