bryanyang0528 commented on a change in pull request #5004: [AIRFLOW-4187] SlackWebhookOperator do not pass http_conn_id to its parent class URL: https://github.com/apache/airflow/pull/5004#discussion_r270492480
########## File path: tests/contrib/hooks/test_slack_webhook_hook.py ########## @@ -91,6 +92,16 @@ def test_build_slack_message(self): # Then self.assertEqual(self.expected_message, message) + def test_get_base_url_default(self): + hook = SlackWebhookHook(http_conn_id='http_default') + hook.get_conn() + + self.assertEqual(hook._get_base_url(), 'https://www.google.com/') Review comment: According to this article:https://stackoverflow.com/questions/52054427/how-to-integrate-apache-airflow-with-slack/52054663 SlackWebhookOperator could be set like this: ``` from airflow.contrib.operators.slack_webhook_operator import SlackWebhookOperator slack_msg="Hi Wssup?" slack_test = SlackWebhookOperator( task_id='slack_test', http_conn_id='slack_connection', webhook_token='/1234/abcd', message=slack_msg, channel='#airflow_updates', username='airflow_'+os.environ['ENVIRONMENT'], icon_emoji=None, link_names=False, dag=dag) ``` And set the host of slack in connection like this: `host=https://hooks.slack.com/services/` The argument-`http_conn_id` will be used for getting the hostname of Slack. But in the current version, `http_conn_id` can't be passed to the parent class-`HTTPHOOK`, so that `HTTPHook` will read the host using the default http_conn_id `http_default` and send the msg to `https://www.google.com/YOUR_ENDPOINT`. This the result ``` [2019-03-29 10:23:21,444] {base_hook.py:83} INFO - Using connection to: id: http_default. Host: https://www.google.com/, Port: None, Schema: None, Login: None, Password: None, extra: {} [2019-03-29 10:23:21,446] {http_hook.py:128} INFO - Sending 'POST' to url: https://www.google.com/YOUR_ENDPOINT /usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning) [2019-03-29 10:23:21,462] {http_hook.py:142} ERROR - HTTP error: Not Found [2019-03-29 10:23:21,462] {http_hook.py:144} ERROR - <!DOCTYPE html> ``` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services