fix(handlers): log ignored QueryRowContext Scan errors #1914
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 != "" {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user