airflow
airflow copied to clipboard
Refactor SlackWebhookHook in order to use `slack_sdk` instead of HttpHook methods
Fundamental refactor of SlackWebhookHook with breaking changes.
I tried to minimise breaking changes, however main (and hope the only once) braking change SlackWebhookHook not anymore inherit from airflow.providers.http.hooks.http.HttpHook anymore and use slack_sdk.WebhookClient instead
Additional changes:
- Warn user that it is not safe to specify webhook token (url) directly in the Hook and suggest to switch to Airflow Connections.
- Deprecate specify webhook message attribute in
__init__method and mainly use hook attributes only for configure slack_sdk.WebhookClient. It is still possible to set as Hook arguments. - Inform users (always) that it is not possible to change channel, username and icon by use Slack Incoming Webhook. Users might previously use for two reasons: a. Hook and Operators not cover this part b. Hook initially created for use with Legacy Incoming Webhooks based on Slack Integration
- Change SlackWebhookHook arguments in Operators
- Add documentation for Slack Incoming Webhook connection type

Fundamental also mean that main files related to SlackWebhookHook (airflow/providers/slack/hooks/slack_webhook.py,
tests/providers/slack/hooks/test_slack_webhook.py) re-created from scratch
Even with this PR it is not possible to get rid of apache-airflow-providers-http dependency.
Mainly because SlackWebhookOperator inherit from SimpleHttpOperator
https://github.com/apache/airflow/blob/706a618014a6f94d5ead0476f26f79d9714bf93d/airflow/providers/slack/operators/slack_webhook.py#L28-L30
But actually it not use any feature of SimpleHttpOperator just because it overwrite execute method where all internal stuff of SimpleHttpOperator happen.
Changes in SlackWebhookOperator could be done after this PR. In fact this PR contain a lot of changes so it would be difficult to track changes if it done in single PR.
https://github.com/apache/airflow/blob/706a618014a6f94d5ead0476f26f79d9714bf93d/airflow/providers/slack/operators/slack_webhook.py#L94-L110
Slack seems to be a beast - can you plese rebase :) ?
BTW. Thanks from trying to unentangle the mess :D
@Taragolis - are you working on making some of the changes discussed ? I am gearing up to prepare a new provider's wave, so it would be great to merge this one before.
@Taragolis - are you working on making some of the changes discussed ? I am gearing up to prepare a new provider's wave, so it would be great to merge this one before.
Yep. Plan to finish changes by today
Finally all checks passed. Today it takes a bit longer rather than usual.