refactor: centralise JSON parsing via json_utils.safe_json_loads#5858
Open
qizwiz wants to merge 10 commits into
Open
refactor: centralise JSON parsing via json_utils.safe_json_loads#5858qizwiz wants to merge 10 commits into
qizwiz wants to merge 10 commits into
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! |
Covers: well-formed objects/arrays/primitives, malformed input raises ValueError, error message includes context label, __cause__ is JSONDecodeError, unicode content.
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