mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
typed_endpoint: Handle "dataclass_type" pydantic errors.
This commit adds error message for handling "dataclass_type" pydantic errors. An example when this occurs is when group setting value passed to update the setting is invalid like group ID is passed directly and not in an object with "new" field and other invalid values as well.
This commit is contained in:
@@ -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"),
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user