mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-17 07:21:37 +01:00
Add missing errcode
to parse_string
and parse_boolean
(#11542)
This commit is contained in:
parent
afa0a5e4fc
commit
b3bcacf3c1
6 changed files with 13 additions and 12 deletions
1
changelog.d/11542.misc
Normal file
1
changelog.d/11542.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Add missing `errcode` to `parse_string` and `parse_boolean`.
|
|
@ -246,7 +246,7 @@ def parse_boolean_from_args(
|
||||||
message = (
|
message = (
|
||||||
"Boolean query parameter %r must be one of ['true', 'false']"
|
"Boolean query parameter %r must be one of ['true', 'false']"
|
||||||
) % (name,)
|
) % (name,)
|
||||||
raise SynapseError(400, message)
|
raise SynapseError(400, message, errcode=Codes.INVALID_PARAM)
|
||||||
else:
|
else:
|
||||||
if required:
|
if required:
|
||||||
message = "Missing boolean query parameter %r" % (name,)
|
message = "Missing boolean query parameter %r" % (name,)
|
||||||
|
@ -414,7 +414,7 @@ def _parse_string_value(
|
||||||
name,
|
name,
|
||||||
", ".join(repr(v) for v in allowed_values),
|
", ".join(repr(v) for v in allowed_values),
|
||||||
)
|
)
|
||||||
raise SynapseError(400, message)
|
raise SynapseError(400, message, errcode=Codes.INVALID_PARAM)
|
||||||
else:
|
else:
|
||||||
return value_str
|
return value_str
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
|
|
||||||
# invalid search order
|
# invalid search order
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
|
@ -105,7 +105,7 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
|
|
||||||
# invalid destination
|
# invalid destination
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
|
|
|
@ -360,7 +360,7 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||||
channel.code,
|
channel.code,
|
||||||
msg=channel.json_body,
|
msg=channel.json_body,
|
||||||
)
|
)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"Boolean query parameter 'keep_profiles' must be one of ['true', 'false']",
|
"Boolean query parameter 'keep_profiles' must be one of ['true', 'false']",
|
||||||
channel.json_body["error"],
|
channel.json_body["error"],
|
||||||
|
|
|
@ -92,7 +92,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||||
channel.code,
|
channel.code,
|
||||||
msg=channel.json_body,
|
msg=channel.json_body,
|
||||||
)
|
)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
|
|
||||||
# negative from
|
# negative from
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
|
|
|
@ -608,7 +608,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
|
|
||||||
# invalid deactivated
|
# invalid deactivated
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
|
@ -618,7 +618,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
|
|
||||||
# unkown order_by
|
# unkown order_by
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
|
@ -628,7 +628,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
|
|
||||||
# invalid search order
|
# invalid search order
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
|
@ -638,7 +638,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
|
|
||||||
def test_limit(self):
|
def test_limit(self):
|
||||||
"""
|
"""
|
||||||
|
@ -2896,7 +2896,7 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
|
|
||||||
# invalid search order
|
# invalid search order
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
|
@ -2906,7 +2906,7 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||||
|
|
||||||
# negative limit
|
# negative limit
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
|
|
Loading…
Reference in a new issue