Skip to content

fix(workspaces): hand off a departing member's files without binding every file id - #10038

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/handoff-bulk-set-based
Nov 14, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/handoff-bulk-set-based

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Removing a workspace member who owned more files than Postgres's 65,535 bind parameters failed with a 500 and rolled back: the file creator handoff selected every matching file id and then ran update ... where id in (<every id>)
  • handoffFileCreatorsInTx is now keyed by the caller's scope predicate throughout: rows are locked FOR UPDATE in id order through a subquery (nothing loaded into memory), version heads load through a subquery, and the final update matches the same predicate
  • Covers all three callers: workspace member removal, Project departure, and organization departure
  • Versioned files (workspace/project) still have their implicit history frozen before the creator changes. The update only moves a versioned file whose head is current, so a file committed after the history pass keeps its creator rather than losing its original-upload attribution
  • Extracted the correlated-column qualification from currentWorkspaceFileVersionNumberSql and added workspaceFileVersionHeadCurrentSql (the SQL form of isVersionHeadCurrent)
  • Audited the remaining inArray calls in the removal and handoff paths (workspace, project, and org handoff, workflow reassignment, org membership removal). They bind workspace, project, member, or invitation ids, which don't grow with the number of rows a member owns

Type of Change

  • Bug fix

Testing

  • New real-Postgres case in shared-resource-handoff.integration.ts: it seeds 66,000 knowledge-base files with generate_series, removes the member through revokeWorkspaceAccessTx, and asserts every file moved to the successor. It fails on the pre-fix code with MAX_PARAMETERS_EXCEEDED on the id-list update and passes with the fix (~9s)
  • bun run test:integration with shared-resource-handoff, file-versions, creator-lifetime, projects foundation, membership-removal-lock-order, managed-membership, and owners: 189 passed
  • Unit tests for file-manager, file-manager-page, file-query, and file-versions: 23 passed
  • biome on the changed files; full type-check and audits are left to CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…every file id

Member removal transferred file creators by selecting the departing member's
file ids and updating with an id list, so a member owning more files than
Postgres's 65,535 bind parameters failed the whole removal transaction.

Every statement in the file creator handoff is now keyed by the caller's scope
predicate: rows are locked in id order through a subquery, version heads load
through a subquery, and the final update matches the same predicate. A
versioned file committed after the history pass keeps its creator until its
history is frozen.
@vercel

vercel Bot commented Nov 14, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 14, 2026 4:21am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Replaces file-ID lists with scope-based queries so member removal can hand off more than 65,535 files.

  • File handoffs use a scope instead of a growing list of file IDs.

No actionable issues found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "fix(workspaces): hand off a departing me..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 6d73cad into staging Nov 14, 2026
62 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/handoff-bulk-set-based branch November 14, 2026 04:25

This branch was previously deployed

1 inactive deployment
Preview — 0c8f5d40 Deployed Nov 14, 2026 by vercel[bot]
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