Skip to content

fix(socket_mode): raise ValueError for an unsupported request payload - #2047

Merged
WilliamBergamin merged 3 commits into
slackapi:mainfrom
WilliamBergamin:fix/socket-mode-request-payload-error
Nov 16, 2026
Merged

WilliamBergamin merged 3 commits into
slackapi:mainfrom
WilliamBergamin:fix/socket-mode-request-payload-error

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

Summary

This pull request makes SocketModeRequest raise the intended ValueError for an unsupported payload type.

  • The constructor's type parameter shadows the builtin, so type(payload) called the request type string and raised TypeError: 'str' object is not callable. That hid the real error message.
  • Using payload.__class__ fixes it. The public type keyword argument doesn't change.

Testing

The new test fails on main and passes on this branch: SocketModeRequest(type="slash_commands", envelope_id="abc-123", payload=123) raises ValueError.

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

WilliamBergamin and others added 2 commits November 16, 2026 15:03
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.48%. Comparing base (33288b9) to head (aae4e3f).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2047      +/-   ##
==========================================
- Coverage   84.49%   84.48%   -0.01%     
==========================================
  Files         118      118              
  Lines       14042    14042              
==========================================
- Hits        11865    11864       -1     
- Misses       2177     2178       +1     

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

@WilliamBergamin
WilliamBergamin marked this pull request as ready for review November 16, 2026 21:36
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner November 16, 2026 21:36
@zimeg zimeg added the bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented label Nov 16, 2026
@zimeg zimeg added this to the 3.47.1 milestone Nov 16, 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! Nice catch on the shadowed type.

@WilliamBergamin
WilliamBergamin merged commit 25c14fb into slackapi:main Nov 16, 2026
19 checks passed
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.

2 participants