matrix-org / matrix-org/matrix-python-sdk

429 responses w/o retry_after_ms cause exception

Open
#193 4 comments 0 reactions 0 assignees View on GitHub
bug upstream
Dominant language
Python
Stars
266
Forks
118
PR merge metrics
No merged PRs in 30d

Description

Sometimes (no idea how this is triggered) synapse sends responses with a 429 status code without the `retry_after_ms` field. In those cases, the python client crashes with a `KeyError` since https://github.com/matrix-org/matrix-python-sdk/blob/401439f020ba79197c719a9b2d51838d833b731e/matrix_client/api.py#L666 unconditionally expects `retry_after_ms` to be available on 429 responses.

A relatively simple solution would be to have our own internal exponential backoff counter that gets reset every time a request succeeds or an explicit `retry_after_ms` value is received.

What do you think?

Contributor guide

Open the contributing guide

Research direction

Start at matrix_client/api.py around line 666 and inspect the 429 response handling. Done means a 429 response without retry_after_ms no longer raises KeyError, while the existing explicit retry_after_ms behavior and the proposed backoff behavior are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.