Skip to content
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

Don't raise on *archived* rate limit errors #159

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

Mr0grog
Copy link
Member

@Mr0grog Mr0grog commented Feb 1, 2024

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, since main is already full of breaking changes scheduled for v0.5.0.

@Mr0grog Mr0grog merged commit 46601e5 into main Feb 1, 2024
15 checks passed
@Mr0grog Mr0grog deleted the 158-archived-responses-can-be-429s-too branch February 1, 2024 18:41
Mr0grog added a commit that referenced this pull request Feb 1, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

WaybackSession not properly handling archived 429 (rate limit) responses
1 participant