Repository navigation
feat(webhooks): scope a delivery to the workspace it belongs to - #263
Conversation
The reason a delivery was ignored was recorded and then never shown, so a workspace watching hundreds of accepted webhooks had no way to learn that every one of them named no issue. List the recent deliveries under Integrations with the reason in words, and count the ones that arrived and changed nothing. Reading them needs integration:manage, because the delivery table is not scoped to a workspace. Also cover the whole path in tests, from a signed delivery to a row on the pulls page, including a merged pull request showing as merged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The delivery log had no workspace, so the recent deliveries list could only be gated on a permission and still showed every workspace's traffic to whoever could read it. Stamp each delivery with the workspace behind its installation, which also covers the most useful diagnostic case: a repository that is not connected here still resolves through the installation, so the workspace sees why its own deliveries changed nothing. A delivery no installation here owns stays unattributed and invisible. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 14 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The schema change alone only reaches a database someone pushes to. A fresh install runs the committed migrations, and CI refuses a schema the migrations do not build, so the column needs a migration of its own. The migration is additive: a nullable column, its foreign key and an index. Nothing is rewritten and nothing is backfilled, so an existing install takes it without downtime and its old rows simply carry no workspace. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
main landed 0003_cute_sway while this branch was open, so both claimed drizzle slot 0003 and the journal conflicted on index 3. Two migrations cannot share a slot: drizzle orders by the journal, so whichever applied first would leave the other permanently unapplied and the deploy guard would keep refusing to build. main's history is the one already applied everywhere, so it wins. 0003_productive_quicksilver is dropped and the same schema change is regenerated from the merged schema as 0004_clear_mandroid. The generated SQL is the same three statements: the nullable column, its cascading foreign key, and the composite index the panel query needs. No drop, no rewrite, no backfill. Adds packages/db/catchup/webhook-delivery-workspace-catchup.sql so a database that is already live can take the same change by hand, which is how this repository applies schema to production. Every statement guards itself, so running it twice is safe.
|
@coderabbitai review |
|
#263 landed first and scoped the delivery query to one workspace. This branch was written before that column existed, so its copy of loadGithubDeliveries still filtered on provider alone, and git offered both sides. Taking this branch's version would have quietly put the cross workspace read back, which is the whole reason #263 went first. main wins for the query. This branch wins for the summary, since #263 predates the outcome fix and carries the sentence that called a failed delivery one that changed nothing. Two tests now hold the scoping down rather than trusting the next merge to resolve it the same way: a second workspace must not see the first one's deliveries, and a delivery nobody could attribute belongs to no workspace at all. Removing the organization predicate turns both red. The delivery fixture attributes to the caller's workspace by default, which it could not do before the column existed.
Why
#260 surfaced why a GitHub delivery changed nothing, but
webhook_deliveryhad no workspace column, so the list could only be gated onintegration:manageand still showed every workspace's traffic to whoever could read it. On a deployment with many workspaces that is both noisy and wrong.The design decision
The obvious move is to attribute a delivery by its repository, since that is what
applyGithubEventalready resolves. That is exactly backwards for diagnostics:repository_not_connectedis the single most useful reason to show a workspace, and repository-based attribution cannot produce it by definition, because there is no repository row to attribute through.So attribution goes through the installation. Every GitHub App payload carries
installation.id, andgithub_installationmaps it to a workspace.Does this work for everybody, not just this deployment
This is the part I went back and checked properly, because Orbit is installed by other people in other places.
Both documented install paths apply the column. The repository now has two, and the docs describe only one:
bun run db:push, which is whatREADME.md,CONTRIBUTING.md,docs/getting-started.mdanddocs/self-hosting.mdall tell people to run. Push applies the schema directly, so the column lands.bun run db:migrate, which is what CI exercises since Refuse to build against a database that is behind the schema #256 and what a fresh clone needs. This PR adds0003_productive_quicksilver.sqlso that path lands too.I verified the second the way CI does rather than assuming: built a database from nothing but the committed migrations and ran the drift check against it.
The migration is additive and safe on an existing install. A nullable
textcolumn, its foreign key, and an index. No table rewrite, no backfill, no default to compute. On Postgres 11 and laterADD COLUMNwithout a volatile default is O(1). The foreign key validates existing rows, but every existing row is null, so there is nothing to check. Retention already bounds the table: #253 added a 30 day prune after it reached 23,000 rows.Old rows degrade in the safe direction. Deliveries recorded before this carry no workspace and stop appearing, rather than appearing under the wrong one.
A deployment with no
github_installationrows loses nothing. Its deliveries are unattributed and the list is empty, but that install is already told plainly what is wrong: the integrations page says GitHub is not connected. No diagnostic disappears, it moves somewhere better.Tests
2 new against a real database: a delivery for an unconnected repository is stamped with the workspace behind its installation and still records
repository_not_connected, and a delivery whose installation belongs elsewhere stays unattributed. 28 pass on that route.bun run verifygreen.One thing worth deciding separately
Every install doc still says
bun run db:push, including against a production database. Since #256 the repository also carries committed migrations and CI refuses a schema they do not build. Both work today, so nothing is broken, but a self-hoster following the docs will never rundb:migrate. That belongs with whoever owns #256 rather than in this PR.🤖 Generated with Claude Code
Greptile Summary
The PR attributes GitHub webhook deliveries to workspaces through GitHub App installations and displays workspace-scoped delivery diagnostics.
Confidence Score: 4/5
The PR is not yet safe to merge because the delivery summary can report that every recent webhook changed Orbit even when one failed or completed without a state change.
The existing summary branch still treats every non-ignored delivery as a successful mutation, while current webhook processing can persist failed deliveries and processed deliveries with no synchronization actions.
Files Needing Attention: apps/web/src/features/settings/github-deliveries.tsx
Important Files Changed
Sequence Diagram
sequenceDiagram participant GitHub participant Webhook as GitHub webhook route participant Installations as github_installation participant Deliveries as webhook_delivery participant Settings as Integration settings GitHub->>Webhook: Signed event with installation.id Webhook->>Installations: Resolve installation globally Installations-->>Webhook: organizationId or null Webhook->>Deliveries: Stamp organizationId Webhook->>Webhook: Process event and record status Settings->>Deliveries: Query latest rows by organizationId Deliveries-->>Settings: Workspace-scoped deliveriesReviews (3): Last reviewed commit: "Merge main, and take the migration slot ..." | Re-trigger Greptile