Skip to content

CG-17442: Fix DoubleReactException by handling already_reacted Slack API errors #1061

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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

codegen-sh[bot]
Copy link
Contributor

@codegen-sh codegen-sh bot commented Apr 24, 2025

Description

This PR addresses the Sentry issue CODEGEN_MONITORING_PROD-1CHW where a SlackApiError is thrown with the error message already_reacted when trying to add a reaction to a Slack message that already has that reaction.

Solution

I've created a new utility function safe_add_reaction in the codegen.extensions.slack.utils module that safely adds a reaction to a Slack message, handling the case where the reaction already exists. This function:

  1. Attempts to add the reaction normally
  2. Catches the SlackApiError with the already_reacted error
  3. Logs the information and returns a success response instead of raising an exception

This approach prevents the error from bubbling up and causing the application to crash when a reaction is added multiple times, which can happen due to race conditions or duplicate events from Slack.

Testing

Added comprehensive unit tests for the new utility function, covering:

  • Successful reaction addition
  • Handling of the already_reacted error
  • Re-raising of other Slack API errors

Next Steps

To fully resolve this issue, the show_typing_indicator_slack function in app/modal_app/gen/slack/slack_utils.py should be updated to use this new utility function. However, since that file is not in the current codebase, this PR provides the utility function that can be used by that code when it's updated.

Related Issues

Fixes CG-17442


💻 View my workAbout Codegen

Copy link

codecov bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants