matrix-org / matrix-org/matrix-python-sdk
429 responses w/o retry_after_ms cause exception
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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