summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-05-30 10:47:09 +0100
committerGitHub <noreply@github.com>2022-05-30 10:47:09 +0100
commit796a0312e18c0fd93395ced1d910a251f477a820 (patch)
treee96d54311970cd1042d3c9a6168a0507db7ce9e3 /synapse
parentMutual rooms: Remove dependency on user directory (#12836) (diff)
downloadsynapse-796a0312e18c0fd93395ced1d910a251f477a820.tar.xz
Bump jsonschema stubs (#12912)
Diffstat (limited to 'synapse')
-rw-r--r--synapse/events/validator.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/synapse/events/validator.py b/synapse/events/validator.py
index 360d24274a..29fa9b3880 100644
--- a/synapse/events/validator.py
+++ b/synapse/events/validator.py
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import collections.abc
-from typing import Iterable, Type, Union
+from typing import Iterable, Type, Union, cast
 
 import jsonschema
 
@@ -103,7 +103,12 @@ class EventValidator:
             except jsonschema.ValidationError as e:
                 if e.path:
                     # example: "users_default": '0' is not of type 'integer'
-                    message = '"' + e.path[-1] + '": ' + e.message  # noqa: B306
+                    # cast safety: path entries can be integers, if we fail to validate
+                    # items in an array. However the POWER_LEVELS_SCHEMA doesn't expect
+                    # to see any arrays.
+                    message = (
+                        '"' + cast(str, e.path[-1]) + '": ' + e.message  # noqa: B306
+                    )
                     # jsonschema.ValidationError.message is a valid attribute
                 else:
                     # example: '0' is not of type 'integer'