-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Better handle 404 response for federation /send/ #1866
Conversation
synapse/util/retryutils.py
Outdated
|
||
def __enter__(self): | ||
pass | ||
|
||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
valid_err_code = False | ||
if exc_type is not None and issubclass(exc_type, CodeMessageException): | ||
valid_err_code = exc_val.code != 429 and 0 <= exc_val.code < 500 | ||
if exc_val.code < 400: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe chuck in a short comment explaining what's going on here? Just to explain what a valid_err_code is and why 404, 429 and >500 are special?
synapse/util/retryutils.py
Outdated
# APIs may expect to never received e.g. a 404. It's important to | ||
# handle 404 as some remote servers will return a 404 when the HS | ||
# has been decommissioned. | ||
if exc_val.code < 400: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the exc_val.code < 400
redundant because of the exc_val.code < 500
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, though personally I quite like the fact that each case of code is handled in order. I can change it if you think it makes it clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it misleading because it makes it seem as though 4xx are handled differently to 2xx/3xx.
LGTM apart from the possibly redundant check? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@matrixbot retest this please |
No description provided.