-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Handle HttpResponseException more safely for federated groups #3969
Handle HttpResponseException more safely for federated groups #3969
Conversation
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.
could we have a sytest please?
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() |
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 think you can just return failure
here.
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) |
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.
note that HttpResponseException
has a to_synapse_error
method which you probably want here.
synapse/handlers/groups_local.py
Outdated
def h(failure): | ||
failure.trap(HttpResponseException) | ||
e = failure.value | ||
if e.code >= 400 and e.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.
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?
(otherwise it looks sensible to me) |
(CI is failing due to pep8/import sorting) |
I'll work on sytests next week alongside the other PRs I have. |
Have made a sytest: matrix-org/sytest#512 |
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 otherwise
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