Repository navigation
feat: add Cap Pro Loom concierge migration - #2326
Conversation
|
hey @greptileai, please re-review the PR |
|
hey @greptileai, please re-review the PR |
|
hey @greptileai, please re-review the PR |
|
hey @greptileai, please re-review the PR |
|
hey @greptileai, please re-review the PR |
|
hey @greptileai, please re-review the PR |
… message on status change
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
hey @greptileai, please re-review the PR |
| eq(loomMigrationRequests.id, requestId), | ||
| eq(loomMigrationRequests.status, request.status), | ||
| isNotNull(loomMigrationRequests.activeOrganizationId), | ||
| nextStatus === "completed" | ||
| ? or( | ||
| eq(loomMigrationRequests.activeImportCount, 0), | ||
| lte(loomMigrationRequests.activeImportLeaseUntil, new Date()), |
There was a problem hiding this comment.
Completion can miss imports created after its unfinished-work check
Medium Severity
For an in-progress request, the unfinished-import query can return empty, then a concurrent CSV import or restricted-upload preparation can reserve the request, insert a mapped uploading video, and release its reservation before this UPDATE runs. The status remains in_progress and activeImportCount is back to zero, so both guards pass despite the newly unfinished work. The customer receives a completion notice and the request leaves the queue; a prepared MP4 upload can no longer be finalized because its request is inactive. Lock the request across the unfinished-work check and completion update, or use a version guard that also detects intervening imports.
There was a problem hiding this comment.
Fixed in 5efae8d. Completion now locks the request row (FOR UPDATE), re-checks status and the import lease, and checks unfinished imports with a locking read, all in one transaction. Import paths take the same row lock before they insert mapped work, so they serialize. The new integration test holds an import transaction open while completion runs. It completes on the old code and is blocked on the new code.
| !existing.ownerId || | ||
| !existing.ownerEmail || | ||
| normalizeImportEmail(existing.ownerEmail) !== normalizedEmail || | ||
| !existing.rawFileKey || |
There was a problem hiding this comment.
Failed automatic imports cannot use MP4 recovery
Medium Severity
The automatic-import path in importLoomVideoForOwner creates videoUploads without rawFileKey, and importLoomVideoWorkflow never persists that key. If a concierge CSV import later reaches phase error, this new recovery path rejects it because existing.rawFileKey is null, even with the correct owner and an authorized MP4. Retrying the CSV also rejects the existing video, while completion rejects its mapped error record. Persist or safely derive the automatic import's raw-file key so the operator can recover it without deleting the video or editing database records.
There was a problem hiding this comment.
Fixed in 5efae8d. For an errored automatic import with no stored rawFileKey, the restricted-upload path derives the same key the import workflow writes ({ownerId}/{videoId}/raw-upload.mp4). It saves the key on the upload row inside the lease-checked transaction, so finishing the upload works. An integration test covers recovering a failed CSV import through the MP4 path end to end.
| }), | ||
| ); | ||
| started += result.importedCount; | ||
| failures.push(...result.results.filter((row) => !row.success)); |
There was a problem hiding this comment.
The operator queue discards space-mapping failures
Medium Severity
When space creation, video assignment, or owner membership fails after an import starts, processLoomCsvRows returns success: true together with an error explaining the failed mapping. This filter discards those rows, so the new operator queue reports zero rows needing review and never displays the warning. The video can finish outside its requested space or without the required membership, and retrying the CSV refuses it as already imported. Retain and display rows with errors even when their video import started, distinguishing mapping failures from failed starts.
There was a problem hiding this comment.
Fixed in 5efae8d. The queue now keeps rows that started but returned an error, counts them separately ("started rows need space mapping"), and lists them with their requested space.
…, and surface unmapped rows
|
hey @greptileai, please re-review the PR |
Summary
/dashboard/admin/loom-migrations) imports customer videos through the existing Loom workflow, with a restricted MP4 upload path for videos Loom won't serve.Update for current main
0050_loom_concierge, chained from main's 0049 snapshot. It only createsloom_migration_requestsandloom_migration_imports.emails/catalog edits, since that directory moved to the marketing repo. The transactional templates stay inpackages/database/emails.getNewVideoPublic, so they respect an organization's private-by-default sharing.{ ok: false, error }instead of throwing. Production builds hide thrown server-action messages, so operators and customers would otherwise see a generic error instead of "imports are still processing" or "reconcile the count".pendingrequests toin_progress. It no longer clears an open "Information needed" question.Validation
__tests__/integration/loom-concierge-database.test.tsruns against real MySQL and S3-compatible storage whenCAP_LOOM_CONCIERGE_TEST_DATABASE_URLis set, and skips otherwise. It covers Pro, role and operator access, the one-active-request rule, the information round trip, CSV mapping and duplicates, lease contention and expiry, completion gating, presigned MP4 upload to MinIO, private default visibility, and cross-request isolation.result.mp4, a screenshot and a preview, and the video landed in its Cap space.share-stage-identityunit failures also happen on main and are unrelated.The PR appears safe to merge, with no outstanding correctness or repository-rule issues identified in the latest changes.
Summary
The PR adds a Cap Pro Loom concierge migration workflow for customers and staff, including request tracking, CSV-based imports, restricted MP4 uploads, status notifications, import reservations, and database-backed reconciliation.
Reviews (7) · Last reviewed commit: "fix: account for long Loom concierge imp..."