Skip to content

fix(server): correct poor rate limit responses detection#211

Merged
mdevolde merged 1 commit into
jxmorris12:masterfrom
mdevolde:fix/server_rate_limit
Jul 1, 2026
Merged

fix(server): correct poor rate limit responses detection#211
mdevolde merged 1 commit into
jxmorris12:masterfrom
mdevolde:fix/server_rate_limit

Conversation

@mdevolde

@mdevolde mdevolde commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

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

  • Detect rate limit responses even in JSON responses.

Screenshots (if appropriate):

Not applicable.

How has this been tested?

Applied local tests.

Resources

Not applicable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to documentation only)
  • Refactor / code style update (non-breaking change that improves code structure or readability)
  • Tests / CI improvement (adding or updating tests or CI configuration only)
  • Chore / maintenance (non-breaking change that does not affect functionality, such as updating dependencies or fixing typos)
  • Other (please describe):

Checklist

  • Followed the project's contributing guidelines.
  • Updated any relevant tests.
  • Updated any relevant documentation.
  • Added comments to your code where necessary.
  • Formatted your code, run the linters, checked types and tests.
  • Added your changes to the CHANGELOG file, if applicable.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RateLimitError immediately when _HTTP_STATUS_RATE_LIMIT is returned, before attempting response.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.

Comment thread src/language_tool_python/server.py
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.65%. Comparing base (5441b53) to head (eaea6b8).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mdevolde mdevolde merged commit 9cd9cc0 into jxmorris12:master Jul 1, 2026
13 checks passed
@mdevolde mdevolde deleted the fix/server_rate_limit branch July 1, 2026 12:57
mdevolde added a commit to mdevolde/language_tool_python that referenced this pull request Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants