Repository navigation
test(gke): give the mocked Job the string fields kubernetes 37 requires - #7448
Closed
sushant-me wants to merge 3 commits into
Closed
sushant-me wants to merge 3 commits into
sushant-me wants to merge 3 commits into
Conversation
The A2A executor put str(exception) into the peer-visible failed-task response.
A remote caller that can reach the endpoint therefore receives server-side detail:
absolute filesystem paths, module locations, configuration-key names and upstream
error text - none of which the peer needs, all of which is useful reconnaissance.
The throwable is already logged in full. It is now logged under a short opaque
correlation id, and the peer gets only:
Agent execution failed. (error_id: <12 hex chars>)
Ports the behaviour of adk-java a3df463. ADK_DEBUG_ERRORS=1 restores the old
peer-visible text, for local debugging only and off by default.
Verified: ./pytest tests/unittests/a2a/executor/test_a2a_agent_executor.py
32 passed (30 pre-existing + 2 new)
Fixes google#7445
…acy declaration
build_function_declaration drops the ignored parameters (tool_context) from the
signature rebuilt for the legacy JSON-schema-disabled path, but copied the
original __annotations__ mapping wholesale. typing.get_type_hints() then
resolved annotations for parameters that were no longer present, so a context
parameter annotated with a TYPE_CHECKING-only import raised:
NameError: name 'ToolContext' is not defined
Only annotations for parameters that survive into the new signature are copied
now. This is the legacy-path counterpart of 2ecb3fb, which fixed the same
symptom on the JSON-schema path.
Verified:
ADK_DISABLE_JSON_SCHEMA_FOR_FUNC_DECL=1 python repro.py -> builds, city only
pytest test_function_tool_with_import_annotations.py test_function_tool.py
86 passed (85 pre-existing + 1 new)
kubernetes 37.0.0 validates model fields with pydantic. The mock_k8s_clients
fixture never configured create_namespaced_job's return value, so it handed back
the default MagicMock. GkeCodeExecutor._add_owner_reference copies that Job's
api_version, kind, metadata.name and metadata.uid into a V1OwnerReference, and
those MagicMock values no longer validate as strings:
ValidationError: 4 validation errors for V1OwnerReference
api_version Input should be a valid string [input_type=MagicMock]
execute_code caught the error and returned 'An unexpected executor error
occurred', so five assertions failed and the Unit Tests jobs went red on main
for Python 3.11-3.14.
The fixture now returns a V1Job carrying the string fields a real cluster
returns, which is what the production path sees. No executor code changes.
Verified with kubernetes 37.0.0:
pytest tests/unittests/code_executors/test_gke_code_executor.py
18 passed (0 failed; previously 5 failed)
Fixes google#7443
5 of 7 tasks
This was referenced Oct 16, 2026
Contributor
Author
|
Closing as superseded — current mock_batch_v1.create_namespaced_job.return_value = client.V1Job(
api_version="batch/v1",
kind="Job",
metadata=client.V1ObjectMeta(name="test-job", uid="test-job-uid"),
)That is the same change this PR made — giving the mocked This PR was part of a four-commit stack (#7446 → #7447 → #7448 → #7450), which is why its diff included the a2a and tools changes. I am untangling that in #7446; the other three commits are all redundant now. |
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.
Fixes #7443.
The problem
Since
kubernetes37.0.0, themock_k8s_clientsfixture hands back the defaultMagicMockforcreate_namespaced_job.GkeCodeExecutor._add_owner_referencecopies four fields from that Job into aV1OwnerReference:An unconfigured
MagicMockreturns aMagicMockfor each of those, and kubernetes 37 validates the model with pydantic:execute_codecatches the exception and returns"An unexpected executor error occurred", so five assertions failed and the Unit Tests jobs have been red onmainfor Python 3.11-3.14 since51a20e24.The change
Only the test fixture. It now returns a
V1Jobwith the string fields a real cluster returns:No executor code changes: against a real cluster
create_namespaced_jobalready returns aV1Jobwith string fields, so the production path was never affected. The failure was the mock being less realistic than the API it stands in for.Verification
That matches the expected behaviour in the report — all 18 passing as they do on 36.0.3.
I confirmed the failure without the change first (
ValidationError ... input_type=MagicMock), so the fix is measured against the real regression rather than assumed.