Skip to content

Conversation

@codegen-sh
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

@codecov
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