Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Capitalize "ID" in invalid stream errors in API.
Sahil Batra708204290ece
diff --git a/zerver/lib/streams.py b/zerver/lib/streams.pyindex b978b13f3a2..f2abbd4a6b2 100644--- a/zerver/lib/streams.py+++ b/zerver/lib/streams.py@@ -302,7 +302,7 @@ def check_for_exactly_one_stream_arg(stream_id: Optional[int], stream: Optional[def check_stream_access_for_delete_or_update(user_profile: UserProfile, stream: Stream, sub: Optional[Subscription] = None) -> None:- error = _("Invalid stream id")+ error = _("Invalid stream ID")if stream.realm_id != user_profile.realm_id:raise JsonableError(error)@@ -324,7 +324,7 @@ def access_stream_for_delete_or_update(try:stream = Stream.objects.get(id=stream_id)except Stream.DoesNotExist:- raise JsonableError(_("Invalid stream id"))+ raise JsonableError(_("Invalid stream ID"))try:sub = Subscription.objects.get(@@ -394,7 +394,7 @@ def access_stream_by_id(require_active: bool = True,allow_realm_admin: bool = False,) -> Tuple[Stream, Optional[Subscription]]:- error = _("Invalid stream id")+ error = _("Invalid stream ID")try:stream = get_stream_by_id_in_realm(stream_id, user_profile.realm)except Stream.DoesNotExist:@@ -460,7 +460,7 @@ def access_stream_by_name(def access_web_public_stream(stream_id: int, realm: Realm) -> Stream:- error = _("Invalid stream id")+ error = _("Invalid stream ID")try:stream = get_stream_by_id_in_realm(stream_id, realm)except Stream.DoesNotExist:diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex f2250000e77..acacc26c60e 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -6973,7 +6973,7 @@ paths:- example:{"code": "BAD_REQUEST",- "msg": "Invalid stream id",+ "msg": "Invalid stream ID","result": "error",}description: |@@ -13259,7 +13259,7 @@ paths:- example:{"code": "BAD_REQUEST",- "msg": "Invalid stream id",+ "msg": "Invalid stream ID","result": "error",}description: |@@ -13498,7 +13498,7 @@ paths:- example:{"code": "BAD_REQUEST",- "msg": "Invalid stream id",+ "msg": "Invalid stream ID","result": "error",}description: |@@ -13533,7 +13533,7 @@ paths:- example:{"code": "BAD_REQUEST",- "msg": "Invalid stream id",+ "msg": "Invalid stream ID","result": "error",}description: |@@ -13649,7 +13649,7 @@ paths:- example:{"code": "BAD_REQUEST",- "msg": "Invalid stream id",+ "msg": "Invalid stream ID","result": "error",}description: |diff --git a/zerver/tests/test_drafts.py b/zerver/tests/test_drafts.pyindex 34dc22ad1c5..1e22f84738a 100644--- a/zerver/tests/test_drafts.py+++ b/zerver/tests/test_drafts.py@@ -253,7 +253,7 @@ class DraftCreationTests(ZulipTestCase):"timestamp": 1595479019,}]- self.create_and_check_drafts_for_error(draft_dicts, "Invalid stream id")+ self.create_and_check_drafts_for_error(draft_dicts, "Invalid stream ID")# When the stream itself does not exist:draft_dicts = [@@ -265,7 +265,7 @@ class DraftCreationTests(ZulipTestCase):"timestamp": 1595479019,}]- self.create_and_check_drafts_for_error(draft_dicts, "Invalid stream id")+ self.create_and_check_drafts_for_error(draft_dicts, "Invalid stream ID")def test_create_personal_message_draft_for_non_existing_user(self) -> None:draft_dicts = [diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.pyindex c7903dd24e3..ac21a480b54 100644--- a/zerver/tests/test_message_edit.py+++ b/zerver/tests/test_message_edit.py@@ -1778,7 +1778,7 @@ class EditMessageTest(EditMessageTestCase):},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_move_message_realm_admin_cant_move_to_private_stream_without_subscription(self,@@ -1798,7 +1798,7 @@ class EditMessageTest(EditMessageTestCase):},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_move_message_realm_admin_cant_move_from_private_stream_without_subscription(self,diff --git a/zerver/tests/test_message_flags.py b/zerver/tests/test_message_flags.pyindex b163394c215..578e4cd33be 100644--- a/zerver/tests/test_message_flags.py+++ b/zerver/tests/test_message_flags.py@@ -275,7 +275,7 @@ class UnreadCountTests(ZulipTestCase):"stream_id": invalid_stream_id,},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_mark_all_topics_unread_with_invalid_stream_name(self) -> None:self.login("hamlet")@@ -287,7 +287,7 @@ class UnreadCountTests(ZulipTestCase):"topic_name": "whatever",},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_mark_all_in_stream_topic_read(self) -> None:self.login("hamlet")diff --git a/zerver/tests/test_message_topics.py b/zerver/tests/test_message_topics.pyindex 290c86d6020..f2b87fa76a1 100644--- a/zerver/tests/test_message_topics.py+++ b/zerver/tests/test_message_topics.py@@ -154,7 +154,7 @@ class TopicHistoryTest(ZulipTestCase):# non-sensible stream idendpoint = "/json/users/me/9999999999/topics"result = self.client_get(endpoint, {})- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")# out of realmbad_stream = self.make_stream(@@ -163,7 +163,7 @@ class TopicHistoryTest(ZulipTestCase):)endpoint = f"/json/users/me/{bad_stream.id}/topics"result = self.client_get(endpoint, {})- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")# private stream to which I am not subscribedprivate_stream = self.make_stream(@@ -172,7 +172,7 @@ class TopicHistoryTest(ZulipTestCase):)endpoint = f"/json/users/me/{private_stream.id}/topics"result = self.client_get(endpoint, {})- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_get_topics_web_public_stream_web_public_request(self) -> None:iago = self.example_user("iago")@@ -199,13 +199,13 @@ class TopicHistoryTest(ZulipTestCase):stream = get_stream("Verona", self.example_user("iago").realm)endpoint = f"/json/users/me/{stream.id}/topics"result = self.client_get(endpoint)- self.assert_json_error(result, "Invalid stream id", 400)+ self.assert_json_error(result, "Invalid stream ID", 400)def test_get_topics_non_existent_stream_web_public_request(self) -> None:non_existent_stream_id = 10000000000000000000000endpoint = f"/json/users/me/{non_existent_stream_id}/topics"result = self.client_get(endpoint)- self.assert_json_error(result, "Invalid stream id", 400)+ self.assert_json_error(result, "Invalid stream ID", 400)class TopicDeleteTest(ZulipTestCase):diff --git a/zerver/tests/test_muting_topics.py b/zerver/tests/test_muting_topics.pyindex 49454ae9289..1e360bd31c4 100644--- a/zerver/tests/test_muting_topics.py+++ b/zerver/tests/test_muting_topics.py@@ -186,7 +186,7 @@ class MutedTopicsTests(ZulipTestCase):data = {"stream_id": 999999999, "topic": "Verona3", "op": "add"}result = self.api_patch(user, url, data)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")data = {"topic": "Verona3", "op": "add"}result = self.api_patch(user, url, data)diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.pyindex 3eaf532a2c2..6c72eb89ff9 100644--- a/zerver/tests/test_realm.py+++ b/zerver/tests/test_realm.py@@ -430,7 +430,7 @@ class RealmTest(ZulipTestCase):invalid_notif_stream_id = 1234req = dict(notifications_stream_id=orjson.dumps(invalid_notif_stream_id).decode())result = self.client_patch("/json/realm", req)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")realm = get_realm("zulip")assert realm.notifications_stream is not Noneself.assertNotEqual(realm.notifications_stream.id, invalid_notif_stream_id)@@ -478,7 +478,7 @@ class RealmTest(ZulipTestCase):).decode())result = self.client_patch("/json/realm", req)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")realm = get_realm("zulip")assert realm.signup_notifications_stream is not Noneself.assertNotEqual(diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.pyindex 2746ad58f79..917e657ed5d 100644--- a/zerver/tests/test_subs.py+++ b/zerver/tests/test_subs.py@@ -487,7 +487,7 @@ class StreamAdminTest(ZulipTestCase):}stream_id = get_stream("private_stream_1", user_profile.realm).idresult = self.client_patch(f"/json/streams/{stream_id}", params)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")stream = self.subscribe(user_profile, "private_stream_1")self.assertFalse(stream.is_in_zephyr_realm)@@ -1326,7 +1326,7 @@ class StreamAdminTest(ZulipTestCase):do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)result = self.client_delete("/json/streams/999999999")- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_deactivate_stream_backend_requires_admin(self) -> None:user_profile = self.example_user("hamlet")@@ -1582,7 +1582,7 @@ class StreamAdminTest(ZulipTestCase):"is_private": orjson.dumps(True).decode(),},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_non_admin_cannot_access_unsub_private_stream(self) -> None:iago = self.example_user("iago")@@ -1600,13 +1600,13 @@ class StreamAdminTest(ZulipTestCase):stream_id = get_stream("private_stream_1", hamlet.realm).idresult = self.client_patch(f"/json/streams/{stream_id}", {"new_name": "private_stream_2"})- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")result = self.client_patch(f"/json/streams/{stream_id}",{"description": "new description"},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")result = self.client_patch(f"/json/streams/{stream_id}",@@ -1614,10 +1614,10 @@ class StreamAdminTest(ZulipTestCase):"is_private": orjson.dumps(True).decode(),},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")result = self.client_delete(f"/json/streams/{stream_id}")- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_change_stream_description(self) -> None:user_profile = self.example_user("iago")@@ -2331,13 +2331,13 @@ class StreamAdminTest(ZulipTestCase):stream = self.make_stream("other_realm_stream", realm=other_realm)result = self.client_delete("/json/streams/" + str(stream.id))- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")# Even becoming a realm admin doesn't help us for an out-of-realm# stream.do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)result = self.client_delete("/json/streams/" + str(stream.id))- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_delete_public_stream(self) -> None:"""@@ -2734,7 +2734,7 @@ class DefaultStreamTest(ZulipTestCase):stream = self.make_stream(stream_name, invite_only=True)self.subscribe(self.example_user("iago"), stream_name)result = self.client_post("/json/default_streams", dict(stream_id=stream.id))- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")# Test admin can't add subscribed private stream also.self.subscribe(user_profile, stream_name)@@ -3483,7 +3483,7 @@ class SubscriptionPropertiesTest(ZulipTestCase):).decode()},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_set_invalid_property(self) -> None:"""@@ -3624,7 +3624,7 @@ class SubscriptionRestApiTest(ZulipTestCase):"/api/v1/users/me/subscriptions/121",{"property": "is_muted", "value": "somevalue"},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_bad_add_parameters(self) -> None:user = self.example_user("hamlet")@@ -5499,14 +5499,14 @@ class GetStreamsTest(ZulipTestCase):self.assertEqual(json["stream"]["stream_id"], denmark_stream.id)result = self.client_get("/json/streams/9999")- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")private_stream = self.make_stream("private_stream", invite_only=True)self.subscribe(self.example_user("cordelia"), "private_stream")# Non-admins cannot access unsubscribed private streams.result = self.client_get(f"/json/streams/{private_stream.id}")- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")self.login("iago")result = self.client_get(f"/json/streams/{private_stream.id}")@@ -6069,7 +6069,7 @@ class GetSubscribersTest(ZulipTestCase):# Verify another user can't get the data.self.login("cordelia")result = self.client_get(f"/json/streams/{stream_id}/members")- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")# But an organization administrator canself.login("iago")@@ -6082,7 +6082,7 @@ class GetSubscribersTest(ZulipTestCase):"""stream_id = 99999999result = self.client_get(f"/json/streams/{stream_id}/members")- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")def test_json_get_subscribers(self) -> None:"""@@ -6139,7 +6139,7 @@ class GetSubscribersTest(ZulipTestCase):# Try to fetch the subscriber list as a non-member & non-realm-admin-user.stream_id = get_stream(stream_name, user_profile.realm).idresult = self.make_subscriber_request(stream_id, user=user_profile)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")# Try to fetch the subscriber list as a non-member & realm-admin-user.self.login("iago")@@ -6162,7 +6162,7 @@ class AccessStreamTest(ZulipTestCase):othello = self.example_user("othello")# Nobody can access a stream that doesn't exist- with self.assertRaisesRegex(JsonableError, "Invalid stream id"):+ with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):access_stream_by_id(hamlet, 501232)with self.assertRaisesRegex(JsonableError, "Invalid stream name 'invalid stream'"):access_stream_by_name(hamlet, "invalid stream")@@ -6177,7 +6177,7 @@ class AccessStreamTest(ZulipTestCase):self.assertEqual(sub_ret, sub_ret2)# Othello cannot access the private stream- with self.assertRaisesRegex(JsonableError, "Invalid stream id"):+ with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):access_stream_by_id(othello, stream.id)with self.assertRaisesRegex(JsonableError, "Invalid stream name 'new_private_stream'"):access_stream_by_name(othello, stream.name)@@ -6196,17 +6196,17 @@ class AccessStreamTest(ZulipTestCase):mit_realm = get_realm("zephyr")mit_stream = ensure_stream(mit_realm, "mit_stream", invite_only=False, acting_user=None)sipbtest = self.mit_user("sipbtest")- with self.assertRaisesRegex(JsonableError, "Invalid stream id"):+ with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):access_stream_by_id(hamlet, mit_stream.id)with self.assertRaisesRegex(JsonableError, "Invalid stream name 'mit_stream'"):access_stream_by_name(hamlet, mit_stream.name)- with self.assertRaisesRegex(JsonableError, "Invalid stream id"):+ with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):access_stream_by_id(sipbtest, stream.id)with self.assertRaisesRegex(JsonableError, "Invalid stream name 'new_private_stream'"):access_stream_by_name(sipbtest, stream.name)# MIT realm users cannot access even public streams in their realm- with self.assertRaisesRegex(JsonableError, "Invalid stream id"):+ with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):access_stream_by_id(sipbtest, mit_stream.id)with self.assertRaisesRegex(JsonableError, "Invalid stream name 'mit_stream'"):access_stream_by_name(sipbtest, mit_stream.name)@@ -6223,7 +6223,7 @@ class AccessStreamTest(ZulipTestCase):stream = self.make_stream(stream_name, guest_user_profile.realm, invite_only=False)# Guest user don't have access to unsubscribed public streams- with self.assertRaisesRegex(JsonableError, "Invalid stream id"):+ with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):access_stream_by_id(guest_user_profile, stream.id)# Guest user have access to subscribed public streams@@ -6236,7 +6236,7 @@ class AccessStreamTest(ZulipTestCase):stream_name = "private_stream_1"stream = self.make_stream(stream_name, guest_user_profile.realm, invite_only=True)# Obviously, a guest user doesn't have access to unsubscribed private streams either- with self.assertRaisesRegex(JsonableError, "Invalid stream id"):+ with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):access_stream_by_id(guest_user_profile, stream.id)# Guest user have access to subscribed private streamsdiff --git a/zerver/tests/test_typing.py b/zerver/tests/test_typing.pyindex 0effd5ef6c1..77b59dd0ab7 100644--- a/zerver/tests/test_typing.py+++ b/zerver/tests/test_typing.py@@ -131,7 +131,7 @@ class TypingValidateToArgumentsTest(ZulipTestCase):"topic": topic,},)- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")class TypingHappyPathTestPMs(ZulipTestCase):diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.pyindex b2494d23e2b..5fb6638c01b 100644--- a/zerver/tests/test_users.py+++ b/zerver/tests/test_users.py@@ -1313,7 +1313,7 @@ class UserProfileTest(ZulipTestCase):# Invalid stream ID.result = self.client_get(f"/json/users/{iago.id}/subscriptions/25")- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")result = orjson.loads(self.client_get(f"/json/users/{iago.id}/subscriptions/{stream.id}").content@@ -1352,7 +1352,7 @@ class UserProfileTest(ZulipTestCase):# Unsubscribed non-admins cannot check subscription status in a private stream.self.login("shiva")result = self.client_get(f"/json/users/{iago.id}/subscriptions/{stream.id}")- self.assert_json_error(result, "Invalid stream id")+ self.assert_json_error(result, "Invalid stream ID")# Subscribed non-admins can check subscription status in a private streamself.subscribe(self.example_user("shiva"), stream.name)