Repository navigation
fix: 🐛 enforce max_redirects when fetching a URL - #482
Open
LemonCondor wants to merge 1 commit into
Open
LemonCondor wants to merge 1 commit into
LemonCondor wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Description
URLInputSource.save_to_file()andas_local_input_source()takemax_redirects(default 3), but the value has no effect: the request is sent withfollow_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.Clientused for the download, andhttpx.TooManyRedirectsis reported asMindeeSourceError. httpx still handles the redirects, so relativeLocationheaders 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_redirectsredirects (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 onmainand 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