From 08e8a21da06541f1eedf5db526fe171c0498291b Mon Sep 17 00:00:00 2001 From: yogesh sirsat Date: Fri, 29 Apr 2022 20:38:57 +0530 Subject: [PATCH] custom_profile_fields: Clarify an external account error message. This error message is for a very precise situation -- the pattern not having the desired format. We should say that, rather than a generic "Malformed". --- zerver/lib/validator.py | 2 +- zerver/tests/test_custom_profile_data.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zerver/lib/validator.py b/zerver/lib/validator.py index f50d1fe4f5..e50b33219f 100644 --- a/zerver/lib/validator.py +++ b/zerver/lib/validator.py @@ -365,7 +365,7 @@ def check_external_account_url_pattern(var_name: str, val: object) -> str: s = check_string(var_name, val) if s.count("%(username)s") != 1: - raise ValidationError(_("Malformed URL pattern.")) + raise ValidationError(_("URL pattern must contain '%(username)s'.")) url_val = s.replace("%(username)s", "username") check_url(var_name, url_val) diff --git a/zerver/tests/test_custom_profile_data.py b/zerver/tests/test_custom_profile_data.py index 1071a0f28a..b76cf92cf3 100644 --- a/zerver/tests/test_custom_profile_data.py +++ b/zerver/tests/test_custom_profile_data.py @@ -290,7 +290,7 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): } ).decode() result = self.client_post("/json/realm/profile_fields", info=data) - self.assert_json_error(result, "Malformed URL pattern.") + self.assert_json_error(result, "URL pattern must contain '%(username)s'.") data["field_data"] = orjson.dumps( { @@ -299,7 +299,7 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): } ).decode() result = self.client_post("/json/realm/profile_fields", info=data) - self.assert_json_error(result, "Malformed URL pattern.") + self.assert_json_error(result, "URL pattern must contain '%(username)s'.") data["field_data"] = orjson.dumps( {