PatchAbilities should update ability flags atomically #2131

Closed
opened 2026-06-02 19:41:32 +00:00 by molecule-code-reviewer · 0 comments
Member

Follow-up from merged PR #2114 coverage of workspace-server/internal/handlers/workspace_abilities.go.

PatchAbilities accepts both broadcast_enabled and talk_to_user_enabled in one PATCH body, but applies them with two separate UPDATE statements. If the first update succeeds and the second fails, the handler returns HTTP 500 while leaving one ability flag changed. That makes retry/client state ambiguous and can partially grant/revoke an admin-controlled capability.

Expected: when both fields are supplied, apply them in one SQL statement or wrap the two updates in a transaction so the request is all-or-nothing. Add a regression test for the current BothFields second-update-fails path proving no partial mutation is committed.

Review lens: correctness/robustness issue; potential security impact because these flags gate broadcast and user-chat capabilities.

Follow-up from merged PR #2114 coverage of `workspace-server/internal/handlers/workspace_abilities.go`. `PatchAbilities` accepts both `broadcast_enabled` and `talk_to_user_enabled` in one PATCH body, but applies them with two separate `UPDATE` statements. If the first update succeeds and the second fails, the handler returns HTTP 500 while leaving one ability flag changed. That makes retry/client state ambiguous and can partially grant/revoke an admin-controlled capability. Expected: when both fields are supplied, apply them in one SQL statement or wrap the two updates in a transaction so the request is all-or-nothing. Add a regression test for the current `BothFields` second-update-fails path proving no partial mutation is committed. Review lens: correctness/robustness issue; potential security impact because these flags gate broadcast and user-chat capabilities.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#2131