Skip to content

ref(events): Remove duplicate watch checks in GitHub and Vercel - #2378

Merged
dcramer merged 2 commits into
mainfrom
cleanup/event-subscribable-dedupe
Oct 29, 2026
Merged

dcramer merged 2 commits into
mainfrom
cleanup/event-subscribable-dedupe

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

This is item 1 of #2362 (cleanup, no behavior change).

Each GitHub *Subscribable helper checked GITHUB_WEBHOOK_SECRET again. The Vercel helper took a webhookSecret input for the same reason. Every caller already checked ctx.events.canSubscribe first. Core sets canSubscribe from the plugin's isEnabled, which reads the same secret.

Now each helper takes canSubscribe as an input and returns undefined when it is false. The rule lives in one place, so the tools no longer repeat ctx.events.canSubscribe ? helper(...) : undefined, and a new caller cannot forget the check. The Vercel rule that a commit needs a target stays.

Other changes:

  • The GitHub repository event lists are now defined once, as as const lists in events/repository.ts, like the other event lists. plugin.ts and gitHubRepositorySubscribable both use them. The [...] copies stay because the registration and SubscribableResource types need mutable arrays.
  • gitHubEventKey and pullRequestTargets were copied in webhooks/events.ts and webhooks/check-suite.ts. They now live in a new webhooks/event-targets.ts. Because the helper is shared, check suites no longer have their own copy of the terminal strip, which did nothing there.
  • The terminal field in plugin-api now says to set it only on the exact resource, never on copies for broader resources.

Tests:

  • I deleted the 4 tests that turned the secret off while canSubscribe stayed true. The "host cannot subscribe" tests already cover the gate.
  • I removed secret stubs from tool tests that no longer need them.
  • The core test for watch hints now runs twice, with isEnabled true and false. Before this, no test checked that a disabled plugin gets canSubscribe: false. I extended the existing case instead of adding a new one, because the test architecture check does not allow more setPlugins calls in that file.

Open questions:

  • Is a new webhooks/event-targets.ts the right home for the shared helpers? The other choice was to export them from check-suite.ts. I did not do that, because a reader looking for a general helper would not look in the check-suite file.
  • Make automation events and filters consistent and reliable #2362 also names a "same pattern" in Vercel index.ts and events/deployment.ts. Both only spread VERCEL_DEPLOYMENT_EVENTS, which is already one constant, so I left them as they are.

via David Cramer.

--

View Junior Session [Sentry]

Tools already check ctx.events.canSubscribe before they build a watchable
resource, and canSubscribe comes from the plugin isEnabled check. The
per-helper webhook secret checks only repeated that check.

Also define the GitHub repository event lists once, share gitHubEventKey
and pullRequestTargets between the GitHub normalizers, and document that
terminal goes only on the exact resource.

Refs #2362

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Oct 29, 2026 7:22pm UTC

Request Review

@sentry-evals

sentry-evals Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Sentry Evals

junior-guardian

Run Status Passed Failed Errored Cost Tokens Duration
Head Passed 94 0 0 $0.03 0 25.89s

Base commit 1a5cc18 has no eval run to compare against.

Each GitHub and Vercel *Subscribable helper now takes canSubscribe and
returns undefined when the host cannot create Watches. Tools no longer
repeat the ternary, so a new caller cannot forget the check.

Also mark the GitHub repository event lists as const, like the other
event lists.

Refs #2362

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer merged commit 30bd09c into main Oct 29, 2026
46 checks passed
@dcramer
dcramer deleted the cleanup/event-subscribable-dedupe branch October 29, 2026 19:43

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 0b0b4802 Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant