Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
slack: Don't show error code to users.
Aman Agrawalb57b783dd809
diff --git a/zerver/data_import/slack.py b/zerver/data_import/slack.pyindex 4eb5984ed73..6f187bb8c51 100644--- a/zerver/data_import/slack.py+++ b/zerver/data_import/slack.py@@ -1667,7 +1667,8 @@ def check_token_access(token: str, required_scopes: set[str]) -> None:if not data.json()["ok"]:error = data.json()["error"]if error != "missing_scope":- raise ValueError(f"Invalid Slack token: {token}, {error}")+ logging.error("Slack token is invalid: %s", error)+ raise ValueError(f"Invalid token: {token}")has_scopes = set(data.headers.get("x-oauth-scopes", "").split(","))missing_scopes = required_scopes - has_scopesif missing_scopes:@@ -1675,7 +1676,7 @@ def check_token_access(token: str, required_scopes: set[str]) -> None:f"Slack token is missing the following required scopes: {sorted(missing_scopes)}")else:- raise Exception("Enter a token. Valid tokens start with xoxb-.")+ raise Exception("Invalid token. Valid tokens start with xoxb-.")def get_slack_api_data(diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.pyindex b41ef7c0316..35e7e3444b1 100644--- a/zerver/tests/test_slack_importer.py+++ b/zerver/tests/test_slack_importer.py@@ -366,13 +366,14 @@ class SlackImporter(ZulipTestCase):self.assertEqual(exception_for("xoxq-unknown"),- "Enter a token. Valid tokens start with xoxb-.",+ "Invalid token. Valid tokens start with xoxb-.",)- self.assertEqual(- exception_for("xoxb-invalid-token"),- "Invalid Slack token: xoxb-invalid-token, invalid_auth",- )+ with self.assertLogs(level="ERROR"):+ self.assertEqual(+ exception_for("xoxb-invalid-token"),+ "Invalid token: xoxb-invalid-token",+ )self.assertEqual(exception_for("xoxb-broken-request"),