Skip to content

fix(socket_mode): re-raise the send error instead of AttributeError in websocket_client - #2068

Merged
WilliamBergamin merged 2 commits into
mainfrom
fix/websocket-client-send-retry-error
Nov 19, 2026
Merged

WilliamBergamin merged 2 commits into
mainfrom
fix/websocket-client-send-retry-error

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

Summary

This pull request makes the websocket_client Socket Mode client re-raise the original WebSocketException when a send retry finds the session gone, instead of an AttributeError.

  • Cause: the retry's warning called self.session_id(), which this client never defines (hidden by a type: ignore[attr-defined]), so the warning was never logged and callers catching WebSocketException missed the error.
  • The warning now leaves out the session id, like the class's other log lines; websocket-client's WebSocketApp has no session id.

Testing

The new test fails on main with AttributeError and passes on this branch:

  • A session whose send raises WebSocketException and that reports as disconnected.
  • send_message logs the warning and re-raises the same exception.

Category

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs (Documents)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements

  • 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 have signed the Salesforce CLA (required before your PR can be reviewed or merged).
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

🤖 Generated with Claude Code

…n websocket_client

When a send retry finds the session gone, the warning called self.session_id(),
which the websocket_client SocketModeClient never defines, so callers got an
AttributeError instead of the original WebSocketException and the warning was
never logged. Drop the session id from the message, as the class's other log
lines already do.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.68%. Comparing base (0557021) to head (da9bb48).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2068      +/-   ##
==========================================
+ Coverage   84.67%   84.68%   +0.01%     
==========================================
  Files         118      118              
  Lines       14119    14119              
==========================================
+ Hits        11955    11957       +2     
+ Misses       2164     2162       -2     

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

@WilliamBergamin WilliamBergamin self-assigned this Nov 19, 2026
@WilliamBergamin WilliamBergamin added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch socket-mode labels Nov 19, 2026
@WilliamBergamin
WilliamBergamin marked this pull request as ready for review November 19, 2026 19:02
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner November 19, 2026 19:02

@srtaalej srtaalej left a comment

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.

Ran the new test: it fails on main with AttributeError at the self.session_id() line and passes on this branch ✅ The rest of test_websocket_client.py passes too. I also checked that session_id() exists on the builtin and aiohttp clients but not on this one, so dropping it from the warning is the right fix. LGTM!

@zimeg zimeg added this to the 3.47.1 milestone Nov 19, 2026

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🐍 @WilliamBergamin LGTM! Thanks for fixing the AttributeError so callers get the real WebSocketException.

@WilliamBergamin
WilliamBergamin merged commit 1101cb7 into main Nov 19, 2026
19 checks passed
@WilliamBergamin
WilliamBergamin deleted the fix/websocket-client-send-retry-error branch November 19, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch socket-mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants