Repository navigation
fix(events): preserve subclass validation aliases - #7922
Open
1828703450qqcom-ux wants to merge 1 commit into
Open
1828703450qqcom-ux wants to merge 1 commit into
1828703450qqcom-ux wants to merge 1 commit into
Conversation
Convenience kwargs consumed validation aliases before subclass validation, causing missing fields and unintended workflow routes. Reserve validation alias inputs, including the top-level keys of alias paths and choices, before routing convenience kwargs.
|
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. |
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.
Link to Issue or Description of Change
No existing issue; bug report and reproduction are included below.
Problem:
Event._accept_convenience_kwargspreserves subclass field names andalias, but does not account for Pydantic'svalidation_alias. It consumesmessage,state,route, ornode_pathbefore subclass field validation can read them.For example, the following event should store domain data in
destination, but instead raises a missing-fieldValidationErrorand treats the input asactions.route:The same issue affects
AliasChoicesandAliasPath, including paths nested inside choices. This contradicts the validator's existing contract that subclass fields and their aliases retain normal validation behavior.Solution:
Reserve string validation aliases and the top-level keys consumed by
AliasPath/AliasChoicesbefore routing convenience kwargs. A nested leaf such asAliasPath("payload", "route")does not reserve the unrelated top-levelroutekwarg. Existing field-name and regular-alias handling is retained.Testing Plan
Unit Tests:
Added regression coverage for all four convenience kwargs with string aliases, choices, paths, and choices containing paths (16 cases), plus a nested-leaf boundary case.
Added a real Runner/Workflow regression proving an aliased domain field does not divert execution away from the next node.
All 16 parameterized cases fail against the original implementation and pass with this fix.
pytest tests/unittests/events tests/unittests/workflow/test_workflow.py -q: 323 passed on Python 3.13 (5 existing warnings).Supported-version matrix:
tox -q --override 'testenv.commands=pytest tests/unittests/events tests/unittests/workflow/test_workflow.py -q'passes on Python 3.11, 3.12, 3.13, and 3.14, with 323 passing tests per version.mypy src/google/adk/events/event.py: Success: no issues found in 1 source file.Formatting, Ruff, isort, pyink, and codespell checks pass. Three repository-local hooks cannot launch through their Unix shebangs on Windows (
/bin/bashmissing / WinError 1920); their equivalent Python entry points were run directly and passed:scripts/check_new_py_files.py --new-dir .,scripts/compliance_checks.pywith the three changed files, andscripts/check_docs.py.Full-suite attempt:
toxcollected 22,656 tests on Python 3.11 and encountered an unrelated failure inTestRemoteA2aAgentResolution.test_ensure_resolved_uses_custom_factory(CustomFactoryhas no_httpx_client, line 643). Running that test against unchangedmainat95d8610ea3445ce9c6d0cf70aed1a0071ddc1e2freproduces the identical failure. The full run was stopped; no full-suite pass is claimed.Additional compatibility check in a disposable checkout combining this PR at
fc4e1ffwith the original workflow route fix fix(workflow): preserve routes when flushing and delegating output #7931 at868a2c6: all event and workflow tests report 1545 passed, 2 failed, 1 xfailed on Python 3.13. Both failures are the same Windows-only ExecuteBashTool approval cases that reproduce on unchanged main (the tool explicitly supports POSIX only). This is an integration check, not a dependency; no integration merge commits are included in this PR.Manual End-to-End (E2E) Tests:
Run the following script from an installed checkout (
uv run python /path/to/repro.py). It uses a realRunner,Workflow, and in-memory session service; no model or cloud credentials are needed.Original
mainfails withValidationError(invalidactions.routeand missingdestination_value). With the fix, the script completes and prints:{"outputs": ["ready", "ready processed"], "routes": [], "errors": []}Checklist
AI assistance: Codex investigated, implemented, and verified this change.