From 2446e19907d11a62e0538888eab5639aa3775fa6 Mon Sep 17 00:00:00 2001 From: Cathy Teng Date: Mon, 1 Jul 2024 10:03:18 -0700 Subject: [PATCH 1/2] set delete_original to false when responding to webhooks --- src/sentry/integrations/slack/webhooks/action.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sentry/integrations/slack/webhooks/action.py b/src/sentry/integrations/slack/webhooks/action.py index bae71b66fe8fb2..cbf5b67154c736 100644 --- a/src/sentry/integrations/slack/webhooks/action.py +++ b/src/sentry/integrations/slack/webhooks/action.py @@ -566,10 +566,13 @@ def _handle_group_actions( try: private_metadata = orjson.loads(view.private_metadata) webhook_client = WebhookClient(private_metadata["orig_response_url"]) - webhook_client.send(blocks=json_blocks) + webhook_client.send(blocks=json_blocks, delete_original=False) logger.info( "slack.webhook.view_submission.success", - extra={"integration_id": slack_request.integration.id}, + extra={ + "integration_id": slack_request.integration.id, + "blocks": json_blocks, + }, ) except SlackApiError as e: logger.error( @@ -687,10 +690,10 @@ def _handle_group_actions( json_blocks = orjson.dumps(response.get("blocks")).decode() webhook_client = WebhookClient(response_url) try: - webhook_client.send(blocks=json_blocks) + webhook_client.send(blocks=json_blocks, delete_original=False) logger.info( "slack.webhook.update_status.success", - extra={"integration_id": slack_request.integration.id}, + extra={"integration_id": slack_request.integration.id, "blocks": json_blocks}, ) except SlackApiError as e: logger.error("slack.webhook.update_status.response-error", extra={"error": str(e)}) From 9d799e2dfb2f939bf4716191a3e13d6330eb1cd0 Mon Sep 17 00:00:00 2001 From: Cathy Teng Date: Mon, 1 Jul 2024 10:11:50 -0700 Subject: [PATCH 2/2] replace original --- src/sentry/integrations/slack/webhooks/action.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sentry/integrations/slack/webhooks/action.py b/src/sentry/integrations/slack/webhooks/action.py index cbf5b67154c736..55ac9d15040f49 100644 --- a/src/sentry/integrations/slack/webhooks/action.py +++ b/src/sentry/integrations/slack/webhooks/action.py @@ -566,7 +566,9 @@ def _handle_group_actions( try: private_metadata = orjson.loads(view.private_metadata) webhook_client = WebhookClient(private_metadata["orig_response_url"]) - webhook_client.send(blocks=json_blocks, delete_original=False) + webhook_client.send( + blocks=json_blocks, delete_original=False, replace_original=True + ) logger.info( "slack.webhook.view_submission.success", extra={ @@ -690,7 +692,9 @@ def _handle_group_actions( json_blocks = orjson.dumps(response.get("blocks")).decode() webhook_client = WebhookClient(response_url) try: - webhook_client.send(blocks=json_blocks, delete_original=False) + webhook_client.send( + blocks=json_blocks, delete_original=False, replace_original=True + ) logger.info( "slack.webhook.update_status.success", extra={"integration_id": slack_request.integration.id, "blocks": json_blocks},