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

Handle HttpResponseException more safely for federated groups - #3969

Merged
turt2live merged 8 commits into
matrix-org:developfrom
turt2live:travis/fix-federated-group-requests
Oct 23, 2018
Merged

turt2live merged 8 commits into
matrix-org:developfrom
turt2live:travis/fix-federated-group-requests

Conversation

@turt2live

@turt2live turt2live commented Sep 26, 2018 •

Copy link
Copy Markdown
Member

This doesn't feel right, but I think it's in the right direction? This fixes element-hq/element-web#7204 although it does so by trapping all 4xx errors and re-throwing them for synapse to handle differently, specifically on the group API.

Riot already has the required bits for handling the 403, but synapse currently returns a 500 instead. See element-hq/element-web#7204 for details.

Sytest: matrix-org/sytest#512

@turt2live
turt2live requested a review from a team September 26, 2018 19:51

@richvdh richvdh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we have a sytest please?

Comment thread synapse/handlers/groups_local.py Outdated
e = failure.value
if e.code >= 400 and e.code < 500:
raise SynapseError(e.code, e.msg)
failure.raiseException()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you can just return failure here.

Comment thread synapse/handlers/groups_local.py Outdated
failure.trap(HttpResponseException)
e = failure.value
if e.code >= 400 and e.code < 500:
raise SynapseError(e.code, e.msg)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

note that HttpResponseException has a to_synapse_error method which you probably want here.

Comment thread synapse/handlers/groups_local.py Outdated
def h(failure):
failure.trap(HttpResponseException)
e = failure.value
if e.code >= 400 and e.code < 500:

@richvdh richvdh Sep 27, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I'd like us to be conservative about which error codes we pass through here; can you start with if e.code == 403 and we'll work up from there?

@richvdh

richvdh commented Sep 27, 2018

Copy link
Copy Markdown
Member

(otherwise it looks sensible to me)

@richvdh

richvdh commented Sep 27, 2018

Copy link
Copy Markdown
Member

(CI is failing due to pep8/import sorting)

@turt2live

Copy link
Copy Markdown
Member Author

I'll work on sytests next week alongside the other PRs I have.

@turt2live

Copy link
Copy Markdown
Member Author

Have made a sytest: matrix-org/sytest#512

@richvdh richvdh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm otherwise

Comment thread synapse/handlers/groups_local.py
@turt2live
turt2live merged commit 43c3f0b into matrix-org:develop Oct 23, 2018
@turt2live
turt2live deleted the travis/fix-federated-group-requests branch October 23, 2018 16:41
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