-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor SlackWebhookHook in order to use slack_sdk
instead of HttpHook methods
#26452
Conversation
675da95
to
7208126
Compare
7208126
to
20c81d7
Compare
Even with this PR it is not possible to get rid of airflow/airflow/providers/slack/operators/slack_webhook.py Lines 28 to 30 in 706a618
But actually it not use any feature of Changes in airflow/airflow/providers/slack/operators/slack_webhook.py Lines 94 to 110 in 706a618
|
Slack seems to be a beast - can you plese rebase :) ? |
BTW. Thanks from trying to unentangle the mess :D |
20c81d7
to
18fbda0
Compare
if any(legacy_attr in body for legacy_attr in ("channel", "username", "icon_emoji", "icon_url")): | ||
warnings.warn( | ||
"You cannot override the default channel (chosen by the user who installed your app), " | ||
"username, or icon when you're using Incoming Webhooks to post messages. " | ||
"Instead, these values will always inherit from the associated Slack app configuration. " | ||
"See: https://api.slack.com/messaging/webhooks#advanced_message_formatting. " | ||
"It is possible to change this values only in Legacy Slack Integration Incoming Webhook: " | ||
"https://api.slack.com/legacy/custom-integrations/messaging/webhooks#legacy-customizations", | ||
UserWarning, | ||
stacklevel=2, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option create separate methods send_legacy
and send_text_legacy
which allow send to Legacy Incoming Webhook without any warnings, might be helpful if there is no possible for user change Legacy Incoming Webhook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there are good reason why it would not be possible, or just " I had no time to change it?". If that's the latter, then this is no problem to have warnings. Warnings are there to be annoying enough to gently push the user to get rid of the legacy code and make investment in doing so. The only reason for allowing to silence warnings easily is when there migtht be really good reasons and use cases that cannot be handled with the "new way" of doing things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one case when user do not have access to create new applications in slack workspace.
One day Slack Webhook based on Slack integrations
will be removed anyway so in user perspective better started to migrated from legacy service to 2 successors: Slack API and Slack Incoming Webhook based on API/App
This might be the later feature if someone requested it and better warn user right now always.
@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 |
9451c8b
to
bbe3be3
Compare
Finally all checks passed. Today it takes a bit longer rather than usual. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor!
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 insteadAdditional changes:
__init__
method and mainly use hook attributes only for configure slack_sdk.WebhookClient. It is still possible to set as Hook arguments.a. Hook and Operators not cover this part
b. Hook initially created for use with Legacy Incoming Webhooks based on Slack Integration
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