Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Better handle 404 response for federation /send/ #1866

Merged
merged 4 commits into from
Feb 1, 2017

Conversation

erikjohnston
Copy link
Member

No description provided.


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:
Copy link
Contributor

@NegativeMjark NegativeMjark Jan 31, 2017

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?

# 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:
Copy link
Contributor

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 ?

Copy link
Member Author

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?

Copy link
Contributor

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.

@NegativeMjark
Copy link
Contributor

LGTM apart from the possibly redundant check?

Copy link
Contributor

@NegativeMjark NegativeMjark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@erikjohnston
Copy link
Member Author

@matrixbot retest this please

@erikjohnston erikjohnston merged commit 06567ec into develop Feb 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants