Skip to content

Migrate the Slack notification workflow to a GitHub App + Cloudflare Worker#7246

Open
GabrielBianconi wants to merge 4 commits intomainfrom
gb/slack-app
Open

Migrate the Slack notification workflow to a GitHub App + Cloudflare Worker#7246
GabrielBianconi wants to merge 4 commits intomainfrom
gb/slack-app

Conversation

@GabrielBianconi
Copy link
Copy Markdown
Member

@GabrielBianconi GabrielBianconi commented Apr 8, 2026

Note

Medium Risk
Replaces a GitHub Actions-based notification workflow with a new externally deployed webhook service, changing auth/secrets handling and delivery path for Slack alerts. Risk is mostly around correct webhook verification, org-membership checks, and operational deployment/configuration in Cloudflare.

Overview
Migrates Slack alerting off the .github/workflows/slack-notifications.yml GitHub Actions workflow (deleted) to a manually deployed Cloudflare Worker under ci/slack-notifications-worker.

Adds a webhook-driven worker (worker.js) that verifies GitHub webhook signatures via a GitHub App, filters out bots and org members via the GitHub API, and posts formatted notifications to Slack for issues, issue comments, PR opens, PR reviews, discussions, and discussion comments. Includes Wrangler config (wrangler.toml), dependencies (package.json/package-lock.json), and setup/deploy documentation (README.md).

Reviewed by Cursor Bugbot for commit 6228102. Bugbot is set up for automated code reviews on this repo. Configure here.

@GabrielBianconi GabrielBianconi self-assigned this Apr 8, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c92899f866

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// --- Post to Slack ---

async function postToSlack(notification, env) {
await fetch("https://slack.com/api/chat.postMessage", {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fail webhook when Slack post is rejected

postToSlack awaits fetch but never checks the HTTP status or Slack's JSON ok field, so the handler still returns 200 OK when Slack rejects the message (for example invalid_auth, missing_scope, or rate-limit responses). In those cases GitHub considers delivery successful and will not retry, which silently drops notifications instead of surfacing an operational failure.

Useful? React with 👍 / 👎.

Comment on lines +67 to +70
function buildNotification(event, payload, env) {
const channel = env.SLACK_CHANNEL;

switch (event) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict notifications to the intended repository

The worker builds notifications for any matching event type without checking payload.repository, so if the GitHub App installation is broadened beyond tensorzero/tensorzero (common with org-level installs), activity from other repos will be forwarded into this Slack channel. This is a behavior regression from the deleted workflow, which was inherently repo-scoped by where it ran, and can leak unrelated repo activity.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6228102. Configure here.

@@ -0,0 +1,14 @@
name = "tensorzero-slack-notifications"
main = "worker.js"
compatibility_date = "2024-01-01"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing nodejs_compat flag breaks worker at runtime

High Severity

The wrangler.toml is missing compatibility_flags = ["nodejs_compat"]. The locked dependency @octokit/webhooks-methods v6.0.0 imports createHmac and timingSafeEqual from node:crypto and Buffer from node:buffer. These Node.js built-in modules are unavailable in Cloudflare Workers without the nodejs_compat flag, so app.webhooks.verify() will fail on every request, making the entire worker non-functional. The compatibility_date also likely needs updating to at least 2024-09-23 for full nodejs_compat v2 polyfill support.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6228102. Configure here.

const isValid = await app.webhooks.verify(
body,
request.headers.get("X-Hub-Signature-256") || "",
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Webhook verify throws on missing signature header

Medium Severity

The || "" fallback for a missing X-Hub-Signature-256 header produces an empty string, which is falsy. The underlying @octokit/webhooks-methods verify() checks !signature and throws a TypeError ("secret, eventPayload & signature required") rather than returning false. This unhandled exception causes the Cloudflare Worker to return a 500 instead of the intended 401 for any request missing the signature header (e.g., scanners, bots, misconfigured clients). A try/catch around the verify call, or a guard checking for a truthy signature before calling verify, would prevent this.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6228102. Configure here.

return true; // 204 = is a member
} catch {
return false; // 404 = not a member
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Broad catch treats API failures as non-members

Low Severity

The bare catch in shouldSkip treats every error from the GitHub API — including authentication failures, rate limiting (403/429), and network errors — the same as a 404 "not a member" response. If the GitHub App credentials become invalid or the API is degraded, every webhook event (including org-member activity) will produce a Slack notification, potentially flooding the channel.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6228102. Configure here.

"dependencies": {
"@octokit/app": "^16.1.2",
"@octokit/core": "^7.0.6",
"@octokit/plugin-paginate-rest": "^14.0.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unused direct dependency @octokit/plugin-paginate-rest

Low Severity

@octokit/plugin-paginate-rest is listed as a direct dependency in package.json but is never imported or used in worker.js. It's already pulled in transitively by @octokit/app. This is unnecessary dead weight in the dependency list.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6228102. Configure here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant