Repository navigation
Conversation
Collaborator
|
Response from ADK Triaging Agent Hello @qizwiz, thank you for creating this PR! We appreciate your contribution to centralising JSON error handling. However, to help us review your PR more efficiently, please ensure it aligns with our Contribution Guidelines. Specifically, we noticed the following items are missing:
Providing this information and coverage will save time for the PR review and ensure code quality. Thank you! |
Collaborator
|
Hi @qizwiz , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please fix the failing tests before we can proceed with the review. |
Covers: well-formed objects/arrays/primitives, malformed input raises ValueError, error message includes context label, __cause__ is JSONDecodeError, unicode content.
The json_utils refactor replaced json.loads with safe_json_loads in validate_schema, but also accidentally deleted schema_to_json_schema. This function is used by _workflow_hitl_utils.py (added in main after the branch was created) causing ImportError across the entire test suite. Also fix test_context_none_no_suffix: the assertion checked for any ' in ' substring, which appears in the json.JSONDecodeError body text itself. Now checks the message prefix format directly.
…afe_json_loads json.JSONDecodeError is a subclass of ValueError, but safe_json_loads raises ValueError directly. Two handlers were catching json.JSONDecodeError and would silently stop catching errors after the refactor: - Streaming chunk loop (line ~576): changed except json.JSONDecodeError → ValueError - _parse_streaming_chunk args block: removed dead try/except since safe_json_loads already raises ValueError with context='streaming response'
qizwiz
force-pushed
the
fix/safe-json-loads
branch
from
May 27, 2026 22:27
6544eb1 to
f485b3c
Compare
copybara-service Bot
pushed a commit
that referenced
this pull request
Aug 18, 2026
…ites This CL introduces `_json_utils.safe_json_loads` to provide a uniform ValueError when JSON parsing fails, wrapping the underlying json.JSONDecodeError. Initial callsites in evaluations, sessions, and some models have been migrated. Merge #5858 PiperOrigin-RevId: 966722835
Collaborator
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.
Summary
Centralises all JSON parsing behind a single
safe_json_loads(text, context)helper inutils/json_utils.py, following the same pattern asyaml_utils.py.json.JSONDecodeErroris always wrapped inValueErrorwith a human-readable message that includes the optionalcontextlabelsessions/,tools/,flows/,memory/,agents/Testing plan
tests/unittests/utils/test_json_utils.py(added in this PR): 13 unit tests covering well-formed objects/arrays/primitives, malformed input, error message format with and without context,__cause__chain, and unicode contentsafe_json_loadsis a drop-in replacement; all existing tests continue to pass