Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

typed_endpoint: Handle "dataclass_type" pydantic errors.

Sahil Batrade1e08b9bf8a
diff --git a/zerver/lib/typed_endpoint.py b/zerver/lib/typed_endpoint.py
index f34e24257ab..1d8d7520b37 100644
--- a/zerver/lib/typed_endpoint.py
+++ b/zerver/lib/typed_endpoint.py
@@ -316,6 +316,7 @@ def parse_view_func_signature(
ERROR_TEMPLATES = {
"bool_parsing": _("{var_name} is not a boolean"),
"bool_type": _("{var_name} is not a boolean"),
+ "dataclass_type": _("{var_name} does not have the expected format"),
"datetime_parsing": _("{var_name} is not a date"),
"datetime_type": _("{var_name} is not a date"),
"dict_type": _("{var_name} is not a dict"),
diff --git a/zerver/tests/test_user_groups.py b/zerver/tests/test_user_groups.py
index 0a69fd8e6bd..c3c3dc77cc2 100644
--- a/zerver/tests/test_user_groups.py
+++ b/zerver/tests/test_user_groups.py
@@ -1319,6 +1319,11 @@ class UserGroupAPITestCase(UserGroupTestCase):
leadership_group.deactivated = False
leadership_group.save()
+ # Test updating with value not in the form of GroupSettingChangeRequest
+ params[setting_name] = orjson.dumps(support_group.id).decode()
+ result = self.client_patch(f"/json/user_groups/{leadership_group.id}", info=params)
+ self.assert_json_error(result, f"{setting_name} does not have the expected format")
+
def test_update_user_group_permission_settings(self) -> None:
hamlet = self.example_user("hamlet")
check_add_user_group(hamlet.realm, "support", [hamlet], acting_user=hamlet)