Skip to content

Conversation

@mdevolde
Copy link
Collaborator

@mdevolde mdevolde commented Jan 2, 2026

fix: error handling when http error during LT download

Why the pull request was made

Currently, if there is an HTTP error when trying to access the LanguageTool download URL, there is no handling (except for 404), and an error occurs later when the downloaded file (normally a LanguageTool zip file, but in our case an HTML page with the error code) is unzipped. This error does not allow you to see what is happening (#149).

Summary of changes

  • Added HTTP error codes handling (a specific handling for 403, and a general handling for non 200 codes).
  • Added linked tests.

Screenshots (if appropriate):

Not applicable.

How has this been tested?

  • Tested with a proxy configured to return errors when I try to access the LanguageTool download.
  • Created new tests (linked to new error handling) and applied old ones.

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)
  • 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves error handling when downloading LanguageTool by adding explicit HTTP status code checks beyond the existing 404 handling. Previously, non-404 HTTP errors would result in confusing zip extraction errors when the downloaded content (an HTML error page) was processed.

Key Changes:

  • Added specific error handling for HTTP 403 (Forbidden) responses with helpful context about potential network restrictions
  • Added general error handling for all non-200 HTTP status codes
  • Added comprehensive unit tests for the new error handling paths

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
language_tool_python/download_lt.py Enhanced http_get function with 403-specific and general non-200 status code error handling; updated docstring to reflect new exceptions
tests/test_download.py Added unit tests for 403 Forbidden and other HTTP error codes (500, 502, 503, 504) to verify proper PathError raising with appropriate error messages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mdevolde mdevolde merged commit 17bc25b into jxmorris12:master Jan 2, 2026
14 checks passed
@mdevolde mdevolde deleted the fix-download-error-handling branch January 2, 2026 13:48
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.

1 participant