summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/12912.misc1
-rw-r--r--poetry.lock6
-rw-r--r--synapse/events/validator.py9
3 files changed, 11 insertions, 5 deletions
diff --git a/changelog.d/12912.misc b/changelog.d/12912.misc
new file mode 100644
index 0000000000..6396fd9d36
--- /dev/null
+++ b/changelog.d/12912.misc
@@ -0,0 +1 @@
+Bump types-jsonschema from 4.4.1 to 4.4.6.
diff --git a/poetry.lock b/poetry.lock
index f64d70941e..6b4686545b 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1355,7 +1355,7 @@ python-versions = "*"
 
 [[package]]
 name = "types-jsonschema"
-version = "4.4.1"
+version = "4.4.6"
 description = "Typing stubs for jsonschema"
 category = "dev"
 optional = false
@@ -2618,8 +2618,8 @@ types-ipaddress = [
     {file = "types_ipaddress-1.0.8-py3-none-any.whl", hash = "sha256:4933b74da157ba877b1a705d64f6fa7742745e9ffd65e51011f370c11ebedb55"},
 ]
 types-jsonschema = [
-    {file = "types-jsonschema-4.4.1.tar.gz", hash = "sha256:bd68b75217ebbb33b0242db10047581dad3b061a963a46ee80d4a9044080663e"},
-    {file = "types_jsonschema-4.4.1-py3-none-any.whl", hash = "sha256:ab3ecfdc912d6091cc82f4b7556cfbf1a7cbabc26da0ceaa1cbbc232d1d09971"},
+    {file = "types-jsonschema-4.4.6.tar.gz", hash = "sha256:7f2a804618756768c7c0616f8c794b61fcfe3077c7ee1ad47dcf01c5e5f692bb"},
+    {file = "types_jsonschema-4.4.6-py3-none-any.whl", hash = "sha256:1db9031ca49a8444d01bd2ce8cf2f89318382b04610953b108321e6f8fb03390"},
 ]
 types-opentracing = [
     {file = "types-opentracing-2.4.7.tar.gz", hash = "sha256:be60e9618355aa892571ace002e6b353702538b1c0dc4fbc1c921219d6658830"},
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'