diff --git a/workspace-server/internal/handlers/a2a_queue.go b/workspace-server/internal/handlers/a2a_queue.go index 2792f13ca..5be56dfe6 100644 --- a/workspace-server/internal/handlers/a2a_queue.go +++ b/workspace-server/internal/handlers/a2a_queue.go @@ -160,10 +160,12 @@ func EnqueueA2A( } // Return current queue depth for the caller's visibility. - _ = db.DB.QueryRowContext(ctx, ` + if err := db.DB.QueryRowContext(ctx, ` SELECT COUNT(*) FROM a2a_queue WHERE workspace_id = $1 AND status = 'queued' - `, workspaceID).Scan(&depth) + `, workspaceID).Scan(&depth); err != nil { + log.Printf("A2AQueue: depth query failed for workspace %s: %v", workspaceID, err) + } log.Printf("A2AQueue: enqueued %s for workspace %s (priority=%d, depth=%d)", id, workspaceID, priority, depth) return id, depth, nil @@ -249,10 +251,12 @@ func MarkQueueItemFailed(ctx context.Context, id, errMsg string) { // can see how many ahead of them. func QueueDepth(ctx context.Context, workspaceID string) int { var n int - _ = db.DB.QueryRowContext(ctx, + if err := db.DB.QueryRowContext(ctx, `SELECT COUNT(*) FROM a2a_queue WHERE workspace_id = $1 AND status = 'queued'`, workspaceID, - ).Scan(&n) + ).Scan(&n); err != nil { + log.Printf("A2AQueue: QueueDepth query failed for workspace %s: %v", workspaceID, err) + } return n } diff --git a/workspace-server/internal/handlers/registry.go b/workspace-server/internal/handlers/registry.go index 73e278b39..1b632d6aa 100644 --- a/workspace-server/internal/handlers/registry.go +++ b/workspace-server/internal/handlers/registry.go @@ -530,7 +530,9 @@ func (h *RegistryHandler) Heartbeat(c *gin.Context) { // Read previous current_task to detect changes (before the UPDATE) var prevTask string - _ = db.DB.QueryRowContext(ctx, `SELECT COALESCE(current_task, '') FROM workspaces WHERE id = $1`, payload.WorkspaceID).Scan(&prevTask) + if err := db.DB.QueryRowContext(ctx, `SELECT COALESCE(current_task, '') FROM workspaces WHERE id = $1`, payload.WorkspaceID).Scan(&prevTask); err != nil { + log.Printf("registry heartbeat: prev_task query failed for workspace %s: %v", payload.WorkspaceID, err) + } // #615: Clamp monthly_spend to a safe range before any DB write. // A malicious or buggy agent could report math.MaxInt64, causing @@ -812,10 +814,12 @@ func (h *RegistryHandler) evaluateStatus(c *gin.Context, payload models.Heartbea // timeouts, retry logic, and activity_logs wiring. if h.drainQueue != nil { var maxConcurrent int - _ = db.DB.QueryRowContext(ctx, + if err := db.DB.QueryRowContext(ctx, `SELECT COALESCE(max_concurrent_tasks, 1) FROM workspaces WHERE id = $1`, payload.WorkspaceID, - ).Scan(&maxConcurrent) + ).Scan(&maxConcurrent); err != nil { + log.Printf("registry heartbeat: max_concurrent query failed for workspace %s: %v", payload.WorkspaceID, err) + } if payload.ActiveTasks < maxConcurrent { // context.WithoutCancel: heartbeat handler's ctx is about to // expire as soon as we return. The drain needs to outlive it. diff --git a/workspace-server/internal/handlers/terminal_diagnose.go b/workspace-server/internal/handlers/terminal_diagnose.go index f337ce3db..8528afa0a 100644 --- a/workspace-server/internal/handlers/terminal_diagnose.go +++ b/workspace-server/internal/handlers/terminal_diagnose.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "log" "net/http" "os" "os/exec" @@ -119,9 +120,11 @@ func (h *TerminalHandler) HandleDiagnose(c *gin.Context) { } var instanceID string - _ = 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("terminal diagnose: instance_id query failed for workspace %s: %v", workspaceID, err) + } var res diagnoseResult if instanceID != "" { diff --git a/workspace-server/internal/handlers/workspace.go b/workspace-server/internal/handlers/workspace.go index f6164e646..d466a331a 100644 --- a/workspace-server/internal/handlers/workspace.go +++ b/workspace-server/internal/handlers/workspace.go @@ -996,9 +996,11 @@ func (h *WorkspaceHandler) Get(c *gin.Context) { // the client would otherwise see — the actionable signal // is the 410 + hint, not the timestamp. var removedAt time.Time - _ = db.DB.QueryRowContext(c.Request.Context(), + if err := db.DB.QueryRowContext(c.Request.Context(), `SELECT updated_at FROM workspaces WHERE id = $1`, id, - ).Scan(&removedAt) + ).Scan(&removedAt); err != nil { + log.Printf("workspace GET: removed_at query failed for %s: %v", id, err) + } body := gin.H{ "error": "workspace removed", "id": id,