diff --git a/Packs/Slack/Integrations/SlackV3/SlackV3.py b/Packs/Slack/Integrations/SlackV3/SlackV3.py index 3873ab2c7d28..1bd4a6f36865 100644 --- a/Packs/Slack/Integrations/SlackV3/SlackV3.py +++ b/Packs/Slack/Integrations/SlackV3/SlackV3.py @@ -3491,7 +3491,11 @@ def resolve_conversation_id_from_name(channel_name): channel_id = conversation_info.get("id") if not channel_id: - raise DemistoException(f"Channel '{channel_name}' does not exist.") + raise CortexResourceNotFoundError( + resource_type="Slack channel", + identifier=channel_name, + override_message=f"Channel '{channel_name}' does not exist.", + ) return channel_id @@ -3513,7 +3517,11 @@ def conversation_history() -> None: thread_id = args.get("thread_id") if not conversation_id and not conversation_name: - raise ValueError("Either conversation_id or conversation_name must be provided.") + raise CortexMissingArgError( + ["conversation_id", "conversation_name"], + require_one=True, + override_message="Either conversation_id or conversation_name must be provided.", + ) if not conversation_id: conversation_id = resolve_conversation_id_from_name(conversation_name) @@ -3530,11 +3538,11 @@ def conversation_history() -> None: if page_token: body["cursor"] = page_token - raw_response = send_slack_request_sync(CLIENT, "conversations.history", http_verb="GET", body=body) - - if not raw_response.get("ok"): - raise DemistoException( - f'An error occurred while listing conversation history: {raw_response.get("error")}', res=raw_response + try: + raw_response = send_slack_request_sync(CLIENT, "conversations.history", http_verb="GET", body=body) + except SlackApiError as e: + raise CortexExternalApiError( + override_message=f"An error occurred while listing conversation history: {e.response.get('error')}" ) messages: Any = raw_response.get("messages", []) @@ -3545,8 +3553,8 @@ def conversation_history() -> None: if isinstance(messages, dict): messages = [messages] if not isinstance(messages, list): - raise DemistoException( - f'An error occurred while listing conversation history: {raw_response.get("error")}', res=raw_response + raise CortexExternalApiError( + override_message=f"An error occurred while listing conversation history: {raw_response.get('error')}" ) context: List[Dict[str, Any]] = [] diff --git a/Packs/Slack/Integrations/SlackV3/SlackV3_test.py b/Packs/Slack/Integrations/SlackV3/SlackV3_test.py index 9ca4c006e965..ddaca74f1342 100644 --- a/Packs/Slack/Integrations/SlackV3/SlackV3_test.py +++ b/Packs/Slack/Integrations/SlackV3/SlackV3_test.py @@ -6,6 +6,7 @@ from pytest_mock.plugin import MockerFixture import slack_sdk from CommonServerPython import * +from CommonServerPython import CortexMissingArgError, CortexResourceNotFoundError from slack_sdk.errors import SlackApiError from slack_sdk.web.async_slack_response import AsyncSlackResponse from slack_sdk.web.slack_response import SlackResponse @@ -5459,14 +5460,14 @@ def test_conversation_history_no_channel_provided_error(mocker): Given: A conversation_history command is configured and no channel parameters are provided When: The conversation_history command is called with args missing both conversation_id and conversation_name - Then: The command raises ValueError with appropriate error message + Then: The command raises CortexMissingArgError with appropriate error message """ args = {"limit": "10"} mocker.patch.object(demisto, "args", return_value=args) - with pytest.raises(ValueError, match="Either conversation_id or conversation_name must be provided."): + with pytest.raises(CortexMissingArgError, match="Either conversation_id or conversation_name must be provided."): conversation_history() @@ -5508,12 +5509,12 @@ def test_resolve_conversation_id_from_name_no_channel_found(mocker): Given: The resolve_conversation_id_from_name function is called with a channel name that doesn't exist. When: No private conversation or channel exists for the specified name and channel id is not provided. - Then: The function raises ValueError with appropriate error message indicating the channel was not found. + Then: The function raises CortexResourceNotFoundError with appropriate error message indicating the channel was not found. """ mocker.patch("SlackV3.get_direct_message_channel_id_by_username", return_value=None) mocker.patch("SlackV3.get_conversation_by_name", return_value={}) - with pytest.raises(DemistoException, match="Channel 'nonexistent' does not exist."): + with pytest.raises(CortexResourceNotFoundError, match="Channel 'nonexistent' does not exist."): resolve_conversation_id_from_name("nonexistent") diff --git a/Packs/Slack/ReleaseNotes/3_8_18.md b/Packs/Slack/ReleaseNotes/3_8_18.md new file mode 100644 index 000000000000..9d43d4f61756 --- /dev/null +++ b/Packs/Slack/ReleaseNotes/3_8_18.md @@ -0,0 +1,9 @@ + +#### Integrations + +##### Slack v3 + +- Documentation and metadata improvements. + diff --git a/Packs/Slack/pack_metadata.json b/Packs/Slack/pack_metadata.json index 6985a91869cb..4f129eac03c6 100644 --- a/Packs/Slack/pack_metadata.json +++ b/Packs/Slack/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Slack", "description": "Interact with Slack API - collect logs, send messages and notifications to your Slack team.", "support": "xsoar", - "currentVersion": "3.8.17", + "currentVersion": "3.8.18", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "",