Vitor-Avila commented on code in PR #32336:
URL: https://github.com/apache/superset/pull/32336#discussion_r1982301199
##########
superset/commands/report/execute.py:
##########
@@ -139,22 +139,37 @@ def update_report_schedule_slack_v2(self) -> None:
slack_recipients =
json.loads(recipient.recipient_config_json)
# we need to ensure that existing reports can also fetch
# ids from private channels
+ channels_list =
get_recipients_list(slack_recipients["target"])
+ channels_list = [channel.lstrip("#") for channel in
channels_list]
+ channels = get_channels_with_search(
+ search_string=channels_list,
+ types=[
+ SlackChannelTypes.PRIVATE,
+ SlackChannelTypes.PUBLIC,
+ ],
+ exact_match=True,
+ )
+ if len(channels_list) != len(channels):
+ missing_channels = set(channels_list) - {
+ channel["name"] for channel in channels
+ }
+ msg = (
+ "Could not find the following channels: "
+ f"{', '.join(missing_channels)}"
+ )
+ raise UpdateFailedError(msg)
+ channel_ids = ", ".join(channel["id"] for channel in
channels)
recipient.recipient_config_json = json.dumps(
{
- "target": get_channels_with_search(
- slack_recipients["target"],
- types=[
- SlackChannelTypes.PRIVATE,
- SlackChannelTypes.PUBLIC,
- ],
- )
+ "target": channel_ids,
}
)
except Exception as ex:
- logger.warning(
- "Failed to update slack recipients to v2: %s", str(ex),
exc_info=True
- )
- raise UpdateFailedError from ex
+ # Revert to v1 to preserve configuration (requires manual fix)
+ recipient.type = ReportRecipientType.SLACK
+ msg = f"Failed to update slack recipients to v2: {str(ex)}"
+ logger.error(msg, exc_info=True)
Review Comment:
great catch! I'll do that
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]