Third party event rules Update#6781
Conversation
|
One thing I do not understand: In third_party_rules.py |
|
Ok, I saw that the latest version of the twisted documentation allows for this. Nevermind. |
anoadragon453
left a comment
There was a problem hiding this comment.
Modules are able to import SynapseError (specifically from synapse.module_api.SynapseError) and raise errors themselves. I agree this isn't intuitive though and should probably be added to some documentation or a comment inside of events/third_party_rules.py. This is preferable and more "pythonic" to having modules return error tuples and checking them all over the codebase.
The on_create_room fix is important though, however while dealing with the same functions, a little tangentially related. Could you split that out into a separate PR, while we focus this one on module api error handling?
changelog.d/6781.feature
Outdated
There was a problem hiding this comment.
Changelog entries are read by Synapse maintainers and matrix users, rather than synapse developers, thus we may want to phrase this is a different way. Something along the lines of:
Improve error messages when an action is denied by a third party rule.
perhaps.
|
Thanks for the info about I removed all the tuple return value stuff again so all that remains should be the bugfix for the on room create. I also worked in your remarks, I hope I didn't miss anything. |
anoadragon453
left a comment
There was a problem hiding this comment.
Just a tiny typo.
Now that I think about it though, if modules can raise exceptions, there's not much point in having them return a True or False value. Instead they should just be run, and if no exception is raised, the calling function will continue.
This PR is still useful, but I wonder if the reason on_create_room's return value isn't used is because it was expected to raise an exception on failure.
The docstring doesn't say it's supposed to raise any exceptions though, so 🤷♂️
|
Is it normal that the tests are failing? But it looks to me like it has nothing to do with my changes? |
|
It's due to a brief period on the develop branch where CI is failing that you seem to have branched your PR off of. Just do: to fix it. |
Fixes and additions to third party event rules to function correctly and return custom error messages
Fixed typo Co-Authored-By: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
|
Ok, now I screwed something up... I guess its easier to redo those few changes and make a new PR? |
915534e to
38b2fde
Compare
|
Ok, nevermind. Some git commandline fu and somehow I got it fixed. Not sure how but it seems to build work now :D |
anoadragon453
left a comment
There was a problem hiding this comment.
Looking good, thank you!
|
Thank you very much for your support! |
* commit '99fcc9628': Third party event rules Update (#6781)
Fixes and additions to third party event rules to function correctly and return custom error messages:
This fixes:
And adds:
The tupel option was chosen to guarantee backwards compatibility. Existing forein rules should not break. If the second return value is not given, the default message will be used as it was until now.
Signed-off-by: Peer Diestelhorst <signoff@spy.de>Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.