fix: handle 204 No Content in Client.request#7
Merged
Conversation
Client.request always called response.json(), which crashes with JSONDecodeError when the server returns 204 No Content (empty body). Many REST APIs return 204 for successful PUT/DELETE operations. Now returns None when response has no content.
Move the 204 fix from Planned to Done in the roadmap and set debt D-008 to Paid.
Contributor
|
Claude finished @henriquebastos's task —— View job PR Review Complete ✅Todo List
Review Feedback✅ Overall Assessment: EXCELLENTThis is a well-crafted fix that elegantly resolves a real issue with proper testing and documentation. The implementation follows best practices and integrates seamlessly with the existing codebase. 🔍 Code Quality AnalysisCore Fix ( return response.json() if response.content else NoneStrengths:
🧪 Test Coverage AnalysisNew Test ( def test_highlevel_request_returns_none_on_204_no_content(self, responses):
responses.add("PUT", "https://h/first", status=204, body="")
# ...
assert result is NoneStrengths:
Suggestions for enhancement:
🔒 Security Considerations
⚡ Performance Considerations
📚 Documentation UpdatesThe debt ledger and roadmap updates are thorough and professional:
🏗️ Architecture & Design
🚨 Potential IssuesMinor consideration:
🎯 Final Recommendations
This PR exemplifies excellent software engineering: identifying a real problem, implementing a minimal fix, adding proper test coverage, and maintaining clear documentation. The fix is elegant, safe, and addresses the exact issue described in D-008. |
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.
Why
Client.requestalways calledresponse.json(), which raisesJSONDecodeErroron a 204 No Content (empty body) — common for successfulPUT/DELETE. Closes debt D-008.What
return response.json() if response.content else None— returnsNonewhen the response has no body. Addstests/test_client.pycoverage for the empty-body case.Rebased onto current
main(originally branched pre-Ariad). Folds the Ariad doc coherence: roadmap → Done, debt D-008 → Paid.Validation
pytest: 45 passed locally; CI runs lint + the py3.10–3.13 matrix.pre-commit(ruff 0.11.9) clean.