Don't raise on *archived* rate limit errors #159
Merged
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.
A memento can be a archive of an old rate limit error (status code 429) and in our feverish run to handle rate limit errors better at the end of 2023, we caused
WaybackSession.send()
to raise exceptions for both real rate limits and archived ones. However, the archived ones might be an actual memento that you were looking for, and should have been exempted from raising.This solves the issue by simply checking whether a response is a memento and returning it immediately without doing any other checks, since the effective status code for a memento is always 200. (Checking various attributes of a memento is complicated, so it’s better to just return them right away rather than remembering to make complex exceptions in all the places where various response attributes have to be treated differently for mementos.)
Fixes #158.
After this lands, I’ll cherry-pick it onto a separate
v0.4.x
branch so I can cut a v0.4.5 release with the fix, sincemain
is already full of breaking changes scheduled for v0.5.0.