Skip to content

fix: propagate Socket Mode retry_attempt and retry_reason to BoltRequest headers#1498

Merged
WilliamBergamin merged 1 commit into
slackapi:mainfrom
SAY-5:fix-socket-mode-retry-headers
May 13, 2026
Merged

fix: propagate Socket Mode retry_attempt and retry_reason to BoltRequest headers#1498
WilliamBergamin merged 1 commit into
slackapi:mainfrom
SAY-5:fix-socket-mode-retry-headers

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented May 12, 2026

Summary

In Socket Mode, SocketModeRequest.retry_attempt and SocketModeRequest.retry_reason were dropped when building the Bolt request, so middleware and listeners could not detect Events API retries the way they can in HTTP mode. This synthesizes the x-slack-retry-num / x-slack-retry-reason headers from the envelope so existing retry detection logic works unchanged under Socket Mode. Closes #1484.

Testing

Run python -m pytest tests/adapter_tests/socket_mode/test_internals.py tests/scenario_tests/test_events_socket_mode.py.

Category

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • Others

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run ./scripts/install_all_and_run_tests.sh after making the changes.

Note: I have not yet signed the Salesforce CLA; happy to do so if this is something you would like to accept.

@SAY-5 SAY-5 requested a review from a team as a code owner May 12, 2026 23:37
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.34%. Comparing base (07fb589) to head (1706504).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1498      +/-   ##
==========================================
+ Coverage   91.32%   91.34%   +0.02%     
==========================================
  Files         228      228              
  Lines        7262     7271       +9     
==========================================
+ Hits         6632     6642      +10     
+ Misses        630      629       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 💯 this does solve the issue

I'll merge this PR and follow up with additional unit tests that follow current patterns

from slack_bolt.response import BoltResponse


def build_retry_headers(req: SocketModeRequest) -> Optional[Dict[str, Union[str, Sequence[str]]]]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets name this build_headers 🤔

Suggested change
def build_retry_headers(req: SocketModeRequest) -> Optional[Dict[str, Union[str, Sequence[str]]]]:
def build_headers(req: SocketModeRequest) -> Optional[Dict[str, Union[str, Sequence[str]]]]:

@WilliamBergamin WilliamBergamin merged commit c0dd462 into slackapi:main May 13, 2026
16 checks passed
@WilliamBergamin WilliamBergamin added this to the 1.29.0 milestone May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Socket Mode: retry_attempt and retry_reason are dropped when building AsyncBoltRequest

2 participants