fix(server): correct poor rate limit responses detection#211
Conversation
There was a problem hiding this comment.
Pull request overview
Improves LanguageTool._query_server error handling so rate-limit responses are detected based on HTTP status code (426) rather than only when JSON parsing fails, preventing rate-limited JSON bodies from being returned as successful data.
Changes:
- Raise
RateLimitErrorimmediately when_HTTP_STATUS_RATE_LIMITis returned, before attemptingresponse.json(). - Remove the now-unnecessary rate-limit handling from the JSON decode error path.
- Document the bug fix in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/language_tool_python/server.py | Moves rate-limit detection to happen before JSON parsing so valid JSON rate-limit bodies don’t get treated as successful responses. |
| CHANGELOG.md | Adds an entry describing the fixed rate-limit detection behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #211 +/- ##
=======================================
Coverage 80.65% 80.65%
=======================================
Files 13 13
Lines 1768 1768
=======================================
Hits 1426 1426
Misses 342 342 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fix(server): correct poor rate limit responses detection
Why the pull request was made
To have a better detection of rate limit responses, even if the body of the rate limit become a JSON response.
Summary of changes
Screenshots (if appropriate):
Not applicable.
How has this been tested?
Applied local tests.
Resources
Not applicable.
Types of changes
Checklist