Compare commits

...

1 Commits

Author SHA1 Message Date
fullstack-engineer 18264bb500 fix(handlers): log DB Scan/Exec errors previously silently ignored
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 1m9s
Harness Replays / detect-changes (pull_request) Successful in 44s
CI / Detect changes (pull_request) Successful in 1m38s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 33s
qa-review / approved (pull_request) Successful in 1m2s
gate-check-v3 / gate-check (pull_request) Successful in 1m5s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m51s
security-review / approved (pull_request) Successful in 1m1s
E2E API Smoke Test / detect-changes (pull_request) Successful in 2m15s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 2m13s
sop-tier-check / tier-check (pull_request) Successful in 39s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 1m45s
Harness Replays / Harness Replays (pull_request) Successful in 16s
CI / Canvas (Next.js) (pull_request) Successful in 17s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 16s
CI / Python Lint & Test (pull_request) Successful in 20s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 15s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 3m36s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / Platform (Go) (pull_request) Failing after 12m56s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 13m22s
CI / all-required (pull_request) Successful in 8s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
audit-force-merge / audit (pull_request) Has been skipped
Four sites had chained DB calls where the error was silently discarded:

approvals.go Create: parent workspace lookup Scan error ignored → if the
DB connection fails, the escalation is silently skipped rather than logged.

approvals.go ListAll: auto-expire ExecContext error ignored → stale
approvals accumulate without logging on DB failure.

terminal.go HandleConnect: instance_id lookup Scan error ignored → if the
workspace row lookup fails, the terminal falls through to local Docker
without any diagnostic.

terminal.go handleLocalConnect: workspace name lookup Scan error ignored →
same pattern as above.

Fix: capture and log each error with handler + workspace context so
operators can diagnose DB connectivity or permission issues.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 02:14:35 +00:00
2 changed files with 14 additions and 6 deletions
@@ -60,7 +60,9 @@ func (h *ApprovalsHandler) Create(c *gin.Context) {
// Auto-escalate to parent
var parentID *string
db.DB.QueryRowContext(ctx, `SELECT parent_id FROM workspaces WHERE id = $1`, workspaceID).Scan(&parentID)
if err := db.DB.QueryRowContext(ctx, `SELECT parent_id FROM workspaces WHERE id = $1`, workspaceID).Scan(&parentID); err != nil {
log.Printf("Create approval: parent lookup for workspace %s: %v", workspaceID, err)
}
if parentID != nil {
h.broadcaster.RecordAndBroadcast(ctx, string(events.EventApprovalEscalated), *parentID, map[string]interface{}{
"approval_id": approvalID,
@@ -80,10 +82,12 @@ func (h *ApprovalsHandler) ListAll(c *gin.Context) {
ctx := c.Request.Context()
// Auto-expire stale approvals (older than 10 min)
db.DB.ExecContext(ctx, `
if _, err := db.DB.ExecContext(ctx, `
UPDATE approval_requests SET status = 'denied', decided_by = 'auto-expired', decided_at = now()
WHERE status = 'pending' AND created_at < now() - interval '10 minutes'
`)
`); err != nil {
log.Printf("ListAll: auto-expire stale approvals: %v", err)
}
rows, err := db.DB.QueryContext(ctx, `
SELECT a.id, a.workspace_id, w.name, a.action, a.reason, a.status, a.created_at
@@ -110,9 +110,11 @@ func (h *TerminalHandler) HandleConnect(c *gin.Context) {
// workspace runs as a local Docker container on this tenant.
var instanceID string
if db.DB != nil {
db.DB.QueryRowContext(ctx,
if err := db.DB.QueryRowContext(ctx,
`SELECT COALESCE(instance_id, '') FROM workspaces WHERE id = $1`,
workspaceID).Scan(&instanceID)
workspaceID).Scan(&instanceID); err != nil {
log.Printf("HandleConnect: instance_id lookup for workspace %s: %v", workspaceID, err)
}
}
if instanceID != "" {
@@ -146,7 +148,9 @@ func (h *TerminalHandler) handleLocalConnect(c *gin.Context, workspaceID string)
// Look up workspace name for manual container naming
var wsName string
if db.DB != nil && h.docker != nil {
db.DB.QueryRowContext(ctx, `SELECT LOWER(REPLACE(name, ' ', '-')) FROM workspaces WHERE id = $1`, workspaceID).Scan(&wsName)
if err := db.DB.QueryRowContext(ctx, `SELECT LOWER(REPLACE(name, ' ', '-')) FROM workspaces WHERE id = $1`, workspaceID).Scan(&wsName); err != nil {
log.Printf("HandleConnect: workspace name lookup for %s: %v", workspaceID, err)
}
if wsName != "" {
candidates = append(candidates, wsName)
}