New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Endless history: the history contains a self-reference #6295
Comments
We're aware, see #2690 which is documented in the README. |
I'm confused. I do not talk about the GIT history. I talked about the history of an request. Please, can you reopen my issue? |
Sorry about that! |
You don't need to traverse it recursively. Each response should have the entire history of the prior response. In other words,
You only need to look at this history of the one you're seeing as the final response. It will contain the whole history. |
So, this is a consequence of someone years ago arguing that each history response should have it's own history despite the linearity of the history and the fact that the top-level response has the entire context. What's more helpful (in my view) for looking at this problem is:
Note that the 2nd response (which should have been the redirect request followed from the first item in the history) points to itself, not in fact to the first response. While this is wrong, and can be fixed, it hasn't been noticed in years, because folks that care about the history are just looking at the top-level history (which contains everything) and don't actually need to look at each response's history. I'd be in favor of just wiping those histories altogether instead of trying to make this look more correct. Either way, the place to fix this is in Lines 182 to 183 in 1558590
Namely, the first time through, we are called with the initial response that triggered a redirect, so we're doing hist.append(resp)
resp.history = hist[1:] This is correct because that 0th item in the final response's We could also, write this two other ways: resp.history = hist[:]
hist.append(resp) This will create a new list based off of the existing history we know about, so that initial request will still be ...
Either way should make this work, but I think then, it has downstream affects on Line 190 in 1558590
if len(hist) >= self.max_redirects: |
The history of a requests contains a self-reference to the history owner. The history will be endless.
Expected Result
If I traverse recursive the complete history of a requests, this will be a finally graph.
The history of a request is a tree without cycles.
Actual Result
If I traverse recursive the complete history of a requests, the program breaks with recursive error.
RecursionError: maximum recursion depth exceeded while calling a Python object
The history contains a self-reference to the history owner.
The history of a request is a graph with a cycle.
Reproduction Steps
System Information
The text was updated successfully, but these errors were encountered: