Skip to content

fix(socket-mode): handle Events API payloads without inner events - #2754

Merged
mwbrooks merged 4 commits into
slackapi:mainfrom
kyungyeon-byun-imweb-me:fix/socket-mode-events-without-inner-event
Oct 28, 2026
Merged

mwbrooks merged 4 commits into
slackapi:mainfrom
kyungyeon-byun-imweb-me:fix/socket-mode-events-without-inner-event

Conversation

@kyungyeon-byun-imweb-me

Copy link
Copy Markdown
Contributor

Summary

Fixes #2753.

SocketModeClient currently assumes every events_api payload contains payload.event.type. Slack's documented app_rate_limited payload has its event type at the top level and no inner event, so that assumption throws before consumers can acknowledge the envelope.

This change:

  • dispatches a valid inner event when present, preserving existing behavior;
  • otherwise dispatches a valid top-level payload type, including app_rate_limited;
  • skips only the specific event emission for malformed payloads while preserving the generic slack_event emission and ACK function;
  • adds focused regression coverage for normal callbacks, app_rate_limited, malformed payloads, and invalid inner-event type fallback;
  • includes a patch changeset for @slack/socket-mode.

Validation completed:

  • npm run build --workspace=@slack/logger
  • npm run build --workspace=@slack/types
  • npm run build --workspace=@slack/web-api
  • npm run build --workspace=@slack/socket-mode
  • npm test --workspace=@slack/socket-mode (43 passing)
  • npm run lint

Requirements

@changeset-bot

changeset-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f91f6a4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@slack/socket-mode Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@salesforce-cla

salesforce-cla Bot commented Oct 1, 2026

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @kyungyeon-byun-imweb-me to sign the Salesforce Inc. Contributor License Agreement.

@kyungyeon-byun-imweb-me
kyungyeon-byun-imweb-me marked this pull request as ready for review October 28, 2026 01:32
@kyungyeon-byun-imweb-me
kyungyeon-byun-imweb-me requested a review from a team as a code owner October 28, 2026 01:33
@kyungyeon-byun-imweb-me

Copy link
Copy Markdown
Contributor Author

@salesforce-cla The license agreement has been signed. Thank you.

@mwbrooks mwbrooks added the bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented label Oct 28, 2026
@mwbrooks mwbrooks self-assigned this Oct 28, 2026
@mwbrooks mwbrooks added semver:patch pkg:socket-mode applies to `@slack/socket-mode` labels Oct 28, 2026
@mwbrooks mwbrooks added this to the socket-mode@next milestone Oct 28, 2026

@mwbrooks mwbrooks 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.

✅ Thanks @kyungyeon-byun-imweb-me! 🎉 Congrats on your first contribution to the Node Slack SDK, and thanks for the thorough tests too!

retry_num: event.retry_attempt,
retry_reason: event.retry_reason,
accepts_response_payload: event.accepts_response_payload,
});

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.

suggestion (non-blocking): Could we debug-log when we skip the specific emit? It'll help someone wondering why their listener never fired.

Suggested change
});
} else {
this.logger.debug(`Received an events_api message without an event type (envelope_id: ${event.envelope_id})`);
}

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.

Addressed in df7676a

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2754      +/-   ##
==========================================
+ Coverage   89.28%   89.32%   +0.04%     
==========================================
  Files          65       65              
  Lines       10555    10562       +7     
  Branches      481      489       +8     
==========================================
+ Hits         9424     9435      +11     
+ Misses       1099     1095       -4     
  Partials       32       32              
Flag Coverage Δ
cli-hooks 89.21% <100.00%> (-0.02%) ⬇️
cli-test 89.21% <100.00%> (-0.02%) ⬇️
logger 89.21% <100.00%> (-0.02%) ⬇️
oauth 89.21% <100.00%> (-0.02%) ⬇️
socket-mode 89.21% <100.00%> (-0.02%) ⬇️
web-api 89.21% <100.00%> (-0.02%) ⬇️
webhook 89.21% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@mwbrooks
mwbrooks merged commit b0706c6 into slackapi:main Oct 28, 2026
22 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 cla:signed pkg:socket-mode applies to `@slack/socket-mode` semver:patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SocketModeClient crashes on Events API payloads without an inner event

2 participants