Files
twenty/packages
sonarly-bot bff10a04a1 fix(server): align workspace safety check with cursor semantics
https://sonarly.com/issue/38314?type=bug

Fresh self-host installs can enter a restart loop after creating the first workspace because startup migrations fail a workspace-version safety check that expects a row that is never written for new workspaces.

Fix: I updated the workspace safety check in `run-instance-commands` to align with cursor semantics instead of exact row existence:

1. Replaced `areAllWorkspacesAtCommand({ commandName })` usage with per-workspace cursor validation:
   - Fetch each active/suspended workspace cursor via `getWorkspaceLastAttemptedCommandNameOrThrow`.
   - Validate each cursor has reached or passed the required previous-version tail command using sequence order.

2. Added `UpgradeSequenceReaderService.isStepCompletedOrPassed(...)`:
   - Returns true if cursor is after required step.
   - Returns true on same step only when status is `completed`.
   - Returns false when cursor is before required step.

3. Updated safety-check error wording from “not completed” to “not reached” to match cursor/order-based semantics.

4. Added unit tests in `upgrade-sequence-reader.service.spec.ts` covering:
   - same-step completed (true),
   - same-step failed (false),
   - cursor after step (true),
   - cursor before step (false).

This preserves the intent of the safety gate (prevent unsafe upgrades) while removing false failures for fresh workspaces initialized with a valid later cursor.

Authored by Sonarly by autonomous analysis (run 43722).
2026-05-18 09:11:22 +00:00
..
2026-05-04 11:09:34 +02:00