sadpandajoe commented on code in PR #42089:
URL: https://github.com/apache/superset/pull/42089#discussion_r3694429002


##########
superset/reports/notifications/slack_transport.py:
##########
@@ -0,0 +1,310 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import math
+import time
+from collections.abc import Callable
+from functools import partial
+from typing import TypeVar
+from urllib.error import HTTPError
+
+import backoff
+from flask import current_app as app
+from slack_sdk import WebClient
+from slack_sdk.errors import SlackApiError, SlackRequestError
+
+from superset.reports.notifications.exceptions import (
+    NotificationTransientError,
+    NotificationUnprocessableException,
+)
+from superset.utils.slack import (
+    get_slack_api_error_code,
+    get_slack_api_status_code,
+    is_retryable_slack_transport_error,
+    is_transient_slack_api_error,
+    is_transient_slack_transport_error,
+    SLACK_TRANSIENT_TRANSPORT_ERRORS,
+)
+
+SLACK_API_TIMEOUT_MARGIN = 1
+
+_SlackApiResult = TypeVar("_SlackApiResult")
+
+_SLACK_RETRY_DEADLINE_MESSAGE = (
+    "Slack send retry deadline exceeded; increase SLACK_SEND_RETRY_MAX_TIME "
+    "for slow Slack workspaces or large-file reports"
+)
+
+
+class SlackRetryDeadlineError(Exception):
+    """A Slack operation was skipped because the shared send budget expired."""
+
+    def __init__(self) -> None:
+        super().__init__(_SLACK_RETRY_DEADLINE_MESSAGE)
+
+
+class SlackChannelResponseError(SlackRequestError):
+    """Slack returned malformed channel-specific data before a terminal 
write."""
+
+
+_SLACK_RETRY_ERRORS = (SlackApiError, *SLACK_TRANSIENT_TRANSPORT_ERRORS)

Review Comment:
   Thanks for flagging this. `HTTPError` subclasses `URLError`, and `URLError` 
is already included through `SLACK_TRANSIENT_TRANSPORT_ERRORS` in both tuples. 
The existing parameterized upload test covers 413, 429, and 504 responses: 504 
is retried and aggregated as `NotificationTransientError`, while 413 is 
aggregated as unprocessable. I reran the relevant eight retry and 
channel-isolation cases successfully.



-- 
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]

Reply via email to