Reject an empty top-level value in _string_from_json - #1529
Merged
Conversation
Closes #1487 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YJDy3qA1LyNTh11zS98ukM
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.
Closes #1487.
_string_from_jsonskipped a top-level key whose value was an empty string and carried on searching nested objects for the same key. So a response of the shape{"client_id": "", "someOtherThing": {"clientId": "..."}}returned the nested value — a different field from a different object — as the client ID.An object which has the key we asked for is the object we were looking for. If its value is empty the response is malformed, and that is now a
ValueErrornaming the key rather than a silent fall-through to something else.The recursive calls still suppress
ValueError, so a malformed nested object does not abort the search of its siblings; the strictness applies at whichever level the key actually appears.test_string_from_json_finds_nested_valuesasserted the old behaviour, so it now uses a top-level key that is not one of the wanted keys, and a new test covers the empty-value case.🤖 Generated with Claude Code
https://claude.ai/code/session_01YJDy3qA1LyNTh11zS98ukM