-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
feat: add slackv2 notification #29264
Conversation
745b75d
to
d1bdaa5
Compare
cfbe2ec
to
c156187
Compare
c156187
to
c2f6bf8
Compare
c2f6bf8
to
b1e31fd
Compare
026ac4c
to
eccc201
Compare
superset/reports/schemas.py
Outdated
get_slack_channels_schema = { | ||
"type": "object", | ||
"properties": { | ||
"seach_string": {"type": "string"}, |
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.
NIT: "search_string" vs "seach_string"?
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.
thanks for catching!
1e048b2
to
a0ea944
Compare
a0ea944
to
22968c3
Compare
/testenv up |
@eschutho Ephemeral environment spinning up at http://35.87.151.148:8080. Credentials are |
/testenv up FEATURE_ALERT_REPORTS=true |
@eschutho Ephemeral environment spinning up at http://35.94.230.149:8080. Credentials are |
superset/utils/slack.py
Outdated
search.lower() | ||
for search in (search_string.split(",") if search_string else []) | ||
] | ||
print(channels) |
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.
Did you want to print out channels?
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.
Thanks for catching!
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.
LGTM
a6bf324
to
1b98531
Compare
for search in (search_string.split(",") if search_string else []) | ||
] | ||
|
||
channels = [ |
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.
I'm just staring at this section of the code more and more, do we have good coverage for this function? Looking a this logic, I could see someone making a change and breaking the channels that are returned.
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.
Thanks for all the hard work on this!
@@ -31,6 +46,80 @@ def get_slack_client() -> WebClient: | |||
return WebClient(token=token, proxy=current_app.config["SLACK_PROXY"]) | |||
|
|||
|
|||
def get_channels_with_search( |
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.
So bad that we need this function that seems prone to errors but if Slack does not allow searching, then we are out of luck
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.
Yeah, agree
@@ -94,7 +94,7 @@ def execute(self: Celery.task, report_schedule_id: int) -> None: | |||
).run() | |||
except ReportScheduleUnexpectedError: | |||
logger.exception( | |||
"An unexpected occurred while executing the report: %s", task_id | |||
"An unexpected error occurred while executing the report: %s", task_id |
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 catch
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.
A bunch of minor comments from a second look. Still LGTM.
superset-frontend/src/features/alerts/components/NotificationMethod.test.tsx
Outdated
Show resolved
Hide resolved
); | ||
|
||
const recipientsInput = screen.getByTestId('recipients'); | ||
fireEvent.change(recipientsInput, { |
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.
Can we use userEvent here instead and everywhere else?
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.
I can in two places, but it doesn't work in the others.
superset-frontend/src/features/alerts/components/NotificationMethod.test.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/src/features/alerts/components/NotificationMethod.test.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/src/features/alerts/components/NotificationMethod.test.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/src/features/alerts/components/NotificationMethod.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/src/features/alerts/components/NotificationMethod.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/src/features/alerts/components/NotificationMethod.tsx
Outdated
Show resolved
Hide resolved
return self.response(200, result=channels) | ||
except SupersetException as ex: | ||
logger.error("Error fetching slack channels %s", str(ex)) | ||
return self.response_422(message=str(ex)) |
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.
Do we want to expose the original error message here?
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.
Yes, because it gives information about how to fix the slack issue. Whether it's missing a scope or the channel doesn't exist. Otherwise, it's difficult to know how to unblock the error.
94c337c
to
f7e4a1e
Compare
Ephemeral environment shutdown and build artifacts deleted. |
SUMMARY
SeeSIP
This PR adds a new Notification
SlackV2Notification
that uses the Slack upload files v1 method. It is required for slack workspace owners to add thechannels:read
scope to their workspace in order to use this api. It also fetches all slack channels in order to convert user-inputed names to api-required ids. Because of this, I added a UI to support this.Per the SIP, the both the api and UI will attempt to convert the notification to SlackV2 if the scopes are in place.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
After:
With feature flag on:
Screen.Recording.2024-07-10.at.4.33.54.PM.mov
With feature flag off (after it has been turned on once, so the existing v2 slack reports do not convert back to v1):
Screen.Recording.2024-07-10.at.4.35.23.PM.mov
TESTING INSTRUCTIONS
Create a new slack application and connect it to Superset.
ADDITIONAL INFORMATION