Skip to content

fix: 🐛 enforce max_redirects when fetching a URL - #482

Open
LemonCondor wants to merge 1 commit into
mindee:mainfrom
LemonCondor:fix/url-max-redirects
Open

LemonCondor wants to merge 1 commit into
mindee:mainfrom
LemonCondor:fix/url-max-redirects

Conversation

@LemonCondor

Copy link
Copy Markdown

Description

URLInputSource.save_to_file() and as_local_input_source() take max_redirects (default 3), but the value has no effect: the request is sent with follow_redirects=True, so httpx follows up to its own limit of 20 redirects and the manual redirect loop is never reached.

The limit is now given to the httpx.Client used for the download, and httpx.TooManyRedirects is reported as MindeeSourceError. httpx still handles the redirects, so relative Location headers and the removal of credentials on cross-origin redirects work as before. The unused manual loop is removed.

Behaviour change: a URL needing more than max_redirects redirects (3 by default) is now rejected, as documented.

New tests in tests/v1/input/test_url_input_source.py: the two "too many redirects" cases fail on main and pass with the change. I ran that file, ruff and pylint on the changed files; I did not run the tests that need the private test data submodule.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • 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 change)

This branch has not been deployed

No deployments
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