Skip to content

feat(webhook): warn when URL pattern mismatches webhook class - #2688

Open
zimeg wants to merge 14 commits into
mainfrom
zimeg/webhook-url-mismatch-warning
Open

zimeg wants to merge 14 commits into
mainfrom
zimeg/webhook-url-mismatch-warning

Conversation

@zimeg

@zimeg zimeg commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Summary

This pull request adds a logger to @slack/webhook that warns when a URL looks meant for the other webhook class.

  • IncomingWebhook warns if the URL contains /triggers/, which is likely meant for WebhookTrigger.
  • WebhookTrigger warns if the URL contains /services/, which is likely meant for IncomingWebhook.
  • Both classes accept optional logger and logLevel options, with @slack/logger@^5.0.0 as a new dependency like web-api and socket-mode. A given logger is used as-is, and a logLevel passed with it logs a warning that it was ignored.
  • The check matches the URL path, so it doesn't depend on the host.
  • Adds a minor changeset.

After v4 of slack-github-action, people sent incoming webhook URLs with webhook-type: webhook-trigger, which caused duplicate deliveries, hangs and JSON parse errors (slackapi/slack-github-action#654, slackapi/slack-github-action#671). Those symptoms were fixed in #2674 (@slack/webhook@8.0.1). This warning flags the mismatch itself at construction time, for any consumer of the package.

send() also strips logger and logLevel from payloads, following #2857.

Testing

  • Unit tests for the warning: each class logs on a mismatched URL and stays quiet on a matching one, and a given logger is used as-is when logLevel is also set.
  • npm test --workspace=packages/webhook: 46/46 pass.
  • npm run lint (Biome 2.6.4) is clean.
  • npm run build --workspace=packages/webhook succeeds.
  • With the built package, the default ConsoleLogger prints the warning as webhook:<Class>:<n>, and a custom logger keeps its own level and name.

Requirements

🤖 Generated with Claude Code

Add a logger to @slack/webhook that warns at construction time when:
- IncomingWebhook receives a URL containing "/triggers/"
- WebhookTrigger receives a URL containing "/services/"

This helps catch misconfiguration that causes duplicate deliveries or
hangs (see #654). Both classes now accept optional `logger` and
`logLevel` options via their defaults/options argument.

Refs: #654

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

changeset-bot Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 16d3538

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

This PR includes changesets to release 1 package
Name Type
@slack/webhook Minor

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

@codecov

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.89041% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.51%. Comparing base (d6eb4eb) to head (16d3538).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2688      +/-   ##
==========================================
+ Coverage   94.43%   94.51%   +0.07%     
==========================================
  Files          67       68       +1     
  Lines       10809    10880      +71     
  Branches      679      694      +15     
==========================================
+ Hits        10208    10283      +75     
+ Misses        572      571       -1     
+ Partials       29       26       -3     
Flag Coverage Δ
cli-hooks 94.31% <93.15%> (+0.03%) ⬆️
cli-test 94.31% <93.15%> (+0.03%) ⬆️
logger 94.31% <93.15%> (+0.03%) ⬆️
oauth 94.31% <93.15%> (+0.03%) ⬆️
socket-mode 94.31% <93.15%> (+0.03%) ⬆️
web-api 94.31% <93.15%> (+0.03%) ⬆️
webhook 94.31% <93.15%> (+0.03%) ⬆️

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.

zimeg and others added 3 commits August 4, 2026 15:08
…ogger

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg self-assigned this Sep 30, 2026
@zimeg zimeg added semver:minor enhancement M-T: A feature request for new functionality pkg:webhook applies to `@slack/webhook` labels Sep 30, 2026
zimeg and others added 4 commits November 4, 2026 18:03
Keep @slack/logger beside the newer @slack/types floor from main and regenerate the lockfile.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
A logger passed in options is no longer renamed or reset to INFO. When both
logger and logLevel are given, logLevel is ignored with a debug note, and the
getLogger helper now matches the one in web-api. Existing option fields keep
their original order, with logger and logLevel added after retryConfig.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg added this to the webhook@next milestone Nov 17, 2026
zimeg and others added 2 commits November 16, 2026 16:06
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Sets the logger after the other options and checks for an ignored logLevel in its own case.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg
zimeg marked this pull request as ready for review November 17, 2026 00:37
@zimeg
zimeg requested a review from a team as a code owner November 17, 2026 00:37

@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 @zimeg! Catching the wrong webhook class at construction should save the next person from chasing duplicate deliveries.

Comment thread packages/webhook/src/IncomingWebhook.ts Resolved
Co-authored-by: Michael Brooks <21328+mwbrooks@users.noreply.github.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
zimeg and others added 3 commits November 16, 2026 17:34
This reverts commit 21a2768. The strip for transport options lands first in #2857, then this branch adds logger and logLevel to it.

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

# Conflicts:
#	packages/webhook/src/IncomingWebhook.ts
Co-authored-by: Michael Brooks <21328+mwbrooks@users.noreply.github.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality pkg:webhook applies to `@slack/webhook` semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants