fix(workspace-server): distinguish DB error from not-found in PatchAbilities
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 27s
CI / Detect changes (pull_request) Successful in 29s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 36s
E2E API Smoke Test / detect-changes (pull_request) Successful in 25s
E2E Chat / detect-changes (pull_request) Successful in 24s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 16s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 23s
Harness Replays / detect-changes (pull_request) Successful in 24s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 22s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 19s
qa-review / approved (pull_request) Failing after 16s
gate-check-v3 / gate-check (pull_request) Successful in 19s
sop-checklist / all-items-acked (pull_request) Successful in 31s
security-review / approved (pull_request) Failing after 31s
sop-tier-check / tier-check (pull_request) Successful in 24s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m34s
CI / Python Lint & Test (pull_request) Successful in 8m6s
Harness Replays / Harness Replays (pull_request) Successful in 9s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 11s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 10s
CI / Canvas (Next.js) (pull_request) Successful in 22m53s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m58s
CI / Platform (Go) (pull_request) Successful in 26m59s
CI / all-required (pull_request) Successful in 26m29s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 8m46s
E2E Chat / E2E Chat (pull_request) Failing after 11m15s
CI / Canvas Deploy Reminder (pull_request) Has been skipped

The existence-check condition `err != nil || !exists` conflated two
semantically different outcomes into a single 404 response:

  - err != nil    → DB/internal error → should be 500
  - !exists       → workspace absent  → 404 is correct

Fix: split into two explicit branches. DB errors now return 500 with
a logged reason. The not-found case remains 404.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-16 15:19:29 +00:00
parent bce4844b70
commit 318cd0b580
@@ -51,7 +51,12 @@ func PatchAbilities(c *gin.Context) {
var exists bool
if err := db.DB.QueryRowContext(ctx,
`SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1 AND status != 'removed')`, id,
).Scan(&exists); err != nil || !exists {
).Scan(&exists); err != nil {
log.Printf("PatchAbilities: workspace existence check for %s: %v", id, err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "internal error"})
return
}
if !exists {
c.JSON(http.StatusNotFound, gin.H{"error": "workspace not found"})
return
}