Skip to content

Commit c87ee1e

Browse files
google-genai-botcopybara-github
authored andcommitted
fix: Use correct camelCase functionCallId
PiperOrigin-RevId: 906139925
1 parent 7de5bc5 commit c87ee1e

2 files changed

Lines changed: 45 additions & 5 deletions

File tree

src/google/adk/integrations/agent_identity/gcp_auth_provider.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,7 @@ def _is_consent_completed(context: CallbackContext) -> bool:
200200
for call_id, _ in euc_responses.items():
201201
if call_id in euc_calls:
202202
call = euc_calls[call_id]
203-
if (
204-
call.args
205-
and call.args.get("function_call_id") == target_tool_call_id
206-
):
203+
if call.args and call.args.get("functionCallId") == target_tool_call_id:
207204
return True
208205
return False
209206

tests/unittests/integrations/agent_identity/test_gcp_auth_provider.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from google.adk.agents.callback_context import CallbackContext
2626
from google.adk.auth.auth_credential import AuthCredentialTypes
2727
from google.adk.auth.auth_tool import AuthConfig
28+
from google.adk.auth.auth_tool import AuthToolArguments
2829
from google.adk.flows.llm_flows.functions import REQUEST_EUC_FUNCTION_CALL_NAME
2930
from google.adk.integrations.agent_identity import gcp_auth_provider
3031
from google.adk.integrations.agent_identity import GcpAuthProvider
@@ -399,7 +400,9 @@ async def test_get_auth_credential_returns_token_if_consent_was_completed(
399400
function_call = Mock()
400401
function_call.id = "auth-req-1"
401402
function_call.name = REQUEST_EUC_FUNCTION_CALL_NAME
402-
function_call.args = {"function_call_id": "call-123"}
403+
function_call.args = AuthToolArguments(
404+
function_call_id="call-123", auth_config=auth_config
405+
).model_dump(by_alias=True, exclude_none=True)
403406

404407
event1 = Mock()
405408
event1.get_function_calls.return_value = [function_call]
@@ -432,3 +435,43 @@ async def test_get_auth_credential_returns_token_if_consent_was_completed(
432435
assert auth_credential.auth_type == AuthCredentialTypes.HTTP
433436
assert auth_credential.http.scheme == "bearer"
434437
assert auth_credential.http.credentials.token == "test-token"
438+
439+
440+
async def test_get_auth_credential_raises_error_if_consent_canceled(
441+
mock_operation, auth_config, context, provider
442+
):
443+
function_call = Mock()
444+
function_call.id = "auth-req-1"
445+
function_call.name = REQUEST_EUC_FUNCTION_CALL_NAME
446+
function_call.args = AuthToolArguments(
447+
function_call_id="call-123", auth_config=auth_config
448+
).model_dump(by_alias=True, exclude_none=True)
449+
450+
event1 = Mock()
451+
event1.get_function_calls.return_value = [function_call]
452+
event1.get_function_responses.return_value = []
453+
454+
function_response = Mock()
455+
function_response.id = "auth-req-1"
456+
function_response.name = REQUEST_EUC_FUNCTION_CALL_NAME
457+
458+
event2 = Mock()
459+
event2.get_function_calls.return_value = []
460+
event2.get_function_responses.return_value = [function_response]
461+
462+
context.session.events = [event1, event2]
463+
context.function_call_id = "call-123"
464+
465+
meta = RetrieveCredentialsMetadata({
466+
"uri_consent_required": {
467+
"authorization_uri": "https://example.com/auth",
468+
"consent_nonce": "sample-nonce",
469+
}
470+
})
471+
mock_operation.metadata.value = RetrieveCredentialsMetadata.serialize(meta)
472+
mock_operation.done = False
473+
474+
with pytest.raises(
475+
RuntimeError, match="Failed to retrieve consent based credential."
476+
):
477+
await provider.get_auth_credential(auth_config, context)

0 commit comments

Comments
 (0)