fix json emitter for empty response bodies#178
Merged
demianbrecht merged 5 commits intomainfrom Jul 22, 2025
Merged
Conversation
Collaborator
|
Can you add a CHANGELOG entry? |
bgrant
reviewed
Jul 22, 2025
Co-authored-by: bgrant <robert.grant@salesforce.com>
bgrant
reviewed
Jul 22, 2025
| ) | ||
| seria = self.decode(self.construct()) | ||
| if isinstance(seria, list): | ||
| if len(seria) == 0 or (len(seria) == 1 and len(seria[0]) == 0): |
Collaborator
There was a problem hiding this comment.
I assume in some cases self.decode returns a tuple or something and that's the cause of the clause after the or? Is there a possibility of guessing this wrong and getting an IndexError on that seria[0]?
Member
Author
There was a problem hiding this comment.
The base case (len == 0) is a just in case. What we actually see with our current issue is [""]. No, if we have a list of length 1, it would always be accessible and have a length given it's a string (val.decode("utf8") in self.decode)
lukka5
reviewed
Jul 22, 2025
| self.assertEqual(json.loads(resp), ["foo", "bar"]) | ||
|
|
||
| def test_decode_empty_list(self): | ||
| em = emitters.JSONEmitter([""], lambda: None) |
Collaborator
There was a problem hiding this comment.
for completeness don't we want another test with a truly empty list?
bgrant
previously approved these changes
Jul 22, 2025
lukka5
previously approved these changes
Jul 22, 2025
bgrant
approved these changes
Jul 22, 2025
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.
pyproject.tomlpip installsucceeds with a clean virtualenv