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

Handle HttpResponseException more safely for federated groups #3969

Merged

Conversation

turt2live
Copy link
Member

@turt2live turt2live commented Sep 26, 2018

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
Copy link
Member

@richvdh richvdh left a comment

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?

e = failure.value
if e.code >= 400 and e.code < 500:
raise SynapseError(e.code, e.msg)
failure.raiseException()
Copy link
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.

failure.trap(HttpResponseException)
e = failure.value
if e.code >= 400 and e.code < 500:
raise SynapseError(e.code, e.msg)
Copy link
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.

def h(failure):
failure.trap(HttpResponseException)
e = failure.value
if e.code >= 400 and e.code < 500:
Copy link
Member

@richvdh richvdh Sep 27, 2018

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
Copy link
Member

richvdh commented Sep 27, 2018

(otherwise it looks sensible to me)

@richvdh
Copy link
Member

richvdh commented Sep 27, 2018

(CI is failing due to pep8/import sorting)

@turt2live
Copy link
Member Author

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

@turt2live
Copy link
Member Author

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

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

lgtm otherwise

synapse/handlers/groups_local.py Show resolved Hide resolved
@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