[
https://issues.apache.org/jira/browse/AIRFLOW-4543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17098053#comment-17098053
]
ASF GitHub Bot commented on AIRFLOW-4543:
-----------------------------------------
kaxil commented on pull request #5519:
URL: https://github.com/apache/airflow/pull/5519#issuecomment-622995610
The following diff should also check and fix the issue:
```diff
diff --git a/airflow/providers/slack/hooks/slack.py
b/airflow/providers/slack/hooks/slack.py
index 3a0cd693c..d4d558e7a 100644
--- a/airflow/providers/slack/hooks/slack.py
+++ b/airflow/providers/slack/hooks/slack.py
@@ -80,7 +80,7 @@ class SlackHook(BaseHook):
:param api_params: parameters of the API
"""
slack_client = WebClient(self.token, **self.client_args)
- return_code = slack_client.api_call(method, **api_params)
+ return_code = slack_client.api_call(method, json=api_params)
try:
return_code.validate()
diff --git a/tests/providers/slack/hooks/test_slack.py
b/tests/providers/slack/hooks/test_slack.py
index 1594d8b1d..cfb5c79dc 100644
--- a/tests/providers/slack/hooks/test_slack.py
+++ b/tests/providers/slack/hooks/test_slack.py
@@ -160,3 +160,13 @@ class TestSlackHook(unittest.TestCase):
except AirflowException as exc:
self.assertIn("foo", str(exc))
self.assertIn("bar", str(exc))
+
+ @mock.patch('airflow.providers.slack.hooks.slack.WebClient.api_call',
autospec=True)
+ @mock.patch('airflow.providers.slack.hooks.slack.WebClient')
+ def test_api_call(self, mock_slack_client, mock_slack_api_call):
+ slack_hook = SlackHook(token='test_token')
+ test_api_params = {'channel': 'd'}
+
+ slack_hook.call("chat.postMessage", test_api_params)
+ mock_slack_api_call.assert_called_once_with(
+ mock_slack_client, "chat.postMessage", json=test_api_params)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Update slack operator to support slackclient v2
> -----------------------------------------------
>
> Key: AIRFLOW-4543
> URL: https://issues.apache.org/jira/browse/AIRFLOW-4543
> Project: Apache Airflow
> Issue Type: Improvement
> Components: hooks, operators
> Reporter: Sergio Kef
> Assignee: Sergio Kef
> Priority: Major
>
> Official [Slack API for python|https://pypi.org/project/slackclient/] has
> recently released
> [v.2|https://github.com/slackapi/python-slackclient/wiki/Migrating-to-2.x0]
> Among others some important points:
> * Async IO
> * SSL and Proxy
> * Dropping 2.7 support
> Opening this ticket to work on the upgrade. Current functionalities will be
> migrated and will try to extend functionalities, if possible.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)