fix(restart): guard sync Restart UPDATE against removed/paused/hibernated (#306) #2395

Closed
agent-dev-a wants to merge 1 commits from fix/restart-sync-update-status-guard into main
Member

The sync Restart UPDATE at :306 set status=provisioning with WHERE id = $2 only — no status guard. A workspace removed (or paused/hibernated) between the initial SELECT and the UPDATE could be resurrected to provisioning before the async runRestartCycle guard at :810 fired.

Fix:

  • Add AND status NOT IN (removed, paused, hibernated) to the UPDATE, mirroring the async guard.
  • Check RowsAffected; if 0 rows the workspace is terminal and we return 409 Conflict without broadcasting or provisioning.

Scope: workspace_restart.go + workspace_restart_test.go only.

Regression tests:

  • TestRestartHandler_RemovedWorkspaceBlocked — removed workspace + manual Restart → 409, no resurrection
  • TestRestartHandler_OfflineWorkspaceRestartsNormally — offline workspace → guard passes, proceeds normally

Fixes #306.

The sync Restart UPDATE at :306 set status=provisioning with `WHERE id = $2` only — no status guard. A workspace removed (or paused/hibernated) between the initial SELECT and the UPDATE could be resurrected to provisioning before the async `runRestartCycle` guard at :810 fired. **Fix:** - Add `AND status NOT IN (removed, paused, hibernated)` to the UPDATE, mirroring the async guard. - Check `RowsAffected`; if 0 rows the workspace is terminal and we return 409 Conflict without broadcasting or provisioning. **Scope:** `workspace_restart.go` + `workspace_restart_test.go` only. **Regression tests:** - `TestRestartHandler_RemovedWorkspaceBlocked` — removed workspace + manual Restart → 409, no resurrection - `TestRestartHandler_OfflineWorkspaceRestartsNormally` — offline workspace → guard passes, proceeds normally Fixes #306.
agent-dev-a added 1 commit 2026-06-07 09:36:07 +00:00
fix(restart): guard sync Restart UPDATE against removed/paused/hibernated (#306)
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 3s
CI / Python Lint & Test (pull_request) Successful in 3s
E2E Workspace Lifecycle (staginge2e) / E2E Workspace Lifecycle (staging) (pull_request) Has been skipped
Handlers Postgres Integration / detect-changes (pull_request) Successful in 4s
E2E Chat / detect-changes (pull_request) Successful in 6s
CI / Detect changes (pull_request) Successful in 9s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 4s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 3s
E2E API Smoke Test / detect-changes (pull_request) Successful in 11s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 5s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 11s
sop-checklist / review-refire (pull_request_target) Has been skipped
Harness Replays / detect-changes (pull_request) Successful in 11s
qa-review / approved (pull_request_target) Failing after 5s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / all-items-acked (pull_request_target) Successful in 4s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 1s
sop-tier-check / tier-check (pull_request_target) Failing after 5s
E2E Chat / E2E Chat (pull_request) Successful in 2s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 1s
Harness Replays / Harness Replays (pull_request) Successful in 1s
gate-check-v3 / gate-check (pull_request_target) Successful in 15s
security-review / approved (pull_request_target) Failing after 12s
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Successful in 16s
CI / Canvas (Next.js) (pull_request) Successful in 10s
CI / Canvas Deploy Status (pull_request) Successful in 9s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 58s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 1m0s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 1m12s
E2E Workspace Lifecycle (staginge2e) / E2E Workspace Lifecycle (compile+skip) (pull_request) Successful in 1m38s
CI / Platform (Go) (pull_request) Failing after 7m10s
CI / all-required (pull_request) Has been skipped
audit-force-merge / audit (pull_request_target) Waiting to run
E2E Staging External Runtime / E2E Staging External Runtime (pull_request) Has been cancelled
572b0d9c00
The sync Restart UPDATE at :306 set status='provisioning' with WHERE id
only — no status guard. A workspace removed (or paused/hibernated) between
the initial SELECT and the UPDATE could be resurrected to provisioning
before the async runRestartCycle guard at :810 fired.

Fix: add AND status NOT IN ('removed', 'paused', 'hibernated') to the
UPDATE, mirroring the async guard. Check RowsAffected; if 0 rows the
workspace is terminal and we return 409 Conflict without broadcasting or
provisioning.

Scope: workspace_restart.go + workspace_restart_test.go only.

Regression tests:
- TestRestartHandler_RemovedWorkspaceBlocked: removed → 409, no resurrection
- TestRestartHandler_OfflineWorkspaceRestartsNormally: offline → guard
  passes, proceeds to broadcast + provision
agent-dev-a closed this pull request 2026-06-07 09:54:24 +00:00
Some optional checks failed
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 3s
CI / Python Lint & Test (pull_request) Successful in 3s
E2E Workspace Lifecycle (staginge2e) / E2E Workspace Lifecycle (staging) (pull_request) Has been skipped
Handlers Postgres Integration / detect-changes (pull_request) Successful in 4s
E2E Chat / detect-changes (pull_request) Successful in 6s
CI / Detect changes (pull_request) Successful in 9s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 4s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 3s
E2E API Smoke Test / detect-changes (pull_request) Successful in 11s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 5s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 11s
sop-checklist / review-refire (pull_request_target) Has been skipped
Harness Replays / detect-changes (pull_request) Successful in 11s
qa-review / approved (pull_request_target) Failing after 5s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / all-items-acked (pull_request_target) Successful in 4s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 1s
sop-tier-check / tier-check (pull_request_target) Failing after 5s
E2E Chat / E2E Chat (pull_request) Successful in 2s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 1s
Harness Replays / Harness Replays (pull_request) Successful in 1s
gate-check-v3 / gate-check (pull_request_target) Successful in 15s
security-review / approved (pull_request_target) Failing after 12s
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Successful in 16s
CI / Canvas (Next.js) (pull_request) Successful in 10s
CI / Canvas Deploy Status (pull_request) Successful in 9s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 58s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 1m0s
Required
Details
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 1m12s
Required
Details
E2E Workspace Lifecycle (staginge2e) / E2E Workspace Lifecycle (compile+skip) (pull_request) Successful in 1m38s
CI / Platform (Go) (pull_request) Failing after 7m10s
CI / all-required (pull_request) Has been skipped
Required
Details
audit-force-merge / audit (pull_request_target) Waiting to run
E2E Staging External Runtime / E2E Staging External Runtime (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#2395