Repository navigation
fix(integrations): verify integration ownership before writing a workspace installation - #8234
Conversation
…rkspace Workspace install callbacks now resolve the target workspace from the OAuth code, confirm that this owner holds it, and only then write the Chat SDK installation. A workspace connected to a different owner is rejected before any installation state is written. If a competing integration appears while the install is in flight, the previously stored installation is preserved.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental commit resolves the owner's model policy before the advisory-lock transaction and honors an explicit Assumptions: Files Reviewed (14 files)
Verification notes
Previous Review Summaries (4 snapshots, latest commit 4a7ef18)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 4a7ef18)Status: No Issues Found | Recommendation: Merge Executive SummaryThe incremental change bounds advisory-lock acquisition with the same five-second Assumptions: Files Reviewed (4 files)
Carried-forward findings re-verified during this pass
Previous review (commit 88d8746)Status: 2 Issues Found | Recommendation: Address before merge Executive SummaryThe advisory locks close the install/rollback race the previous review flagged, but the new lock helper omits the lock and statement timeouts every other advisory-lock transaction in this area sets, so waiting installs can pin the primary connection pool. Assumptions: Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (14 files)
Previous review (commit 3560b6c)Status: No Issues Found | Recommendation: Merge Executive SummaryThe follow-up commit resolves the Linear workspace via Files Reviewed (7 files)
Previous review (commit f3ad69a)Status: No Issues Found | Recommendation: Merge Executive SummaryThe install callbacks now resolve the target workspace from the OAuth code and reject a workspace held by another Kilo owner before any Chat SDK installation state is written; the changed production and test code contains no correctness, security, or memory-leak issues I could substantiate. Files Reviewed (7 files)
Reviewed by deepseek-flash-latest · Input: 132.2K · Output: 24K · Cached: 2.9M Review guidance: REVIEW.md from base branch |
Take organizationId and the workspace label from viewer { organization }, the
same lookup the Chat SDK Linear adapter uses to key an installation, so the
install path resolves the workspace without a separate root organization
query.
…wnership-gate # Conflicts: # apps/web/src/lib/integrations/oauth/platforms/linear-callback.ts
|
Changes required before merge: the new Slack rollback can remove another callback’s successful installation. At apps/web/src/lib/integrations/oauth/platforms/slack-callback.ts:163-182, the ownership preflight, shared adapter write, database upsert, and rollback do not form an atomic workspace operation. Two different owners can both pass the preflight. One callback can snapshot no prior installation, another can successfully commit its installation and owner row, and the losing callback can then delete the winner’s shared installation when its upsert detects the conflict. This is a source-derived interleaving, not an executed concurrent callback reproduction. Serialize the entire workspace ownership transition or use an equivalent generation/ownership protocol so rollback cannot overwrite or delete another callback’s installation. Cover concurrent different-owner callbacks and verify the winner remains usable. Also provide separate running-app callback evidence; the recorded route/database suites use provider and installation-store doubles. |
|
bot: Callback persistence now uses provider-owner and provider-workspace transaction advisory locks, with ownership reads and integration writes on that transaction. Installation operations and restoration finish under the locks. Controlled callback regressions pass, and a separate running-app HTTP exercise uses real PostgreSQL and Redis with provider-only network fixtures. Stored-credential usability checks pass for both providers. The PR body records the exact proof head and verification boundaries. |
|
bot: Callback persistence now runs as one serialized workspace transition: the ownership read, the adapter installation write, the integration upsert, and its restoration all execute inside provider-owner then provider-workspace advisory locks with bounded acquisition. A second different-owner callback for the same workspace therefore reaches its ownership check only after the first transition has committed, and receives the existing conflict response without touching shared installation state. Running-app evidence at Real provider consent and enterprise-wide installations remain unproven; the pull request body records the proof head and these limits. |
|
Changes requested: merge |
…wnership-gate # Conflicts: # apps/web/src/app/api/integrations/linear/callback/route.test.ts
…tion The install callbacks now resolve the owner's model policy before taking the workspace locks, and the services treat an explicitly supplied null as a resolved value instead of re-querying the policy inside the transaction.
|
bot: Merged
|
Evidence
Evidence: demonstrated — the running web app completed both providers' connect and callback flows with real application authentication, real PostgreSQL integration rows and real Redis installation storage; only provider network responses were simulated. Focused database and route regressions also passed.
Change
Slack and Linear callback persistence uses primary-PostgreSQL advisory locks, acquired in provider-owner then provider-workspace order. Each transaction sets a five-second lock timeout and a thirty-second SQL statement timeout, matching the existing integration convention. Ownership reads and integration writes use the lock transaction. Adapter installation operations and restoration complete within the protected operation. Organization model defaults are resolved before entering the transaction. Slack credential mirroring uses a savepoint and retains its best-effort behavior. The organization-management configuration from main is preserved.
The coordination contract is documented in the existing security architecture overview.
Verification
Running-app proof head:
b69d978fa2.pnpm --filter web run typecheckpassed; direct webtsgopassed after the test migration.This is nonvisual HTTP and storage behavior; no screenshot is attached.
Production prerequisites
None.
Proxy answers
The owner's proxy gave these answers in the owner's place.