fix(registry): check rows.Err() after iteration in provisiontimeout + healthsweep #2048

Closed
core-be wants to merge 2 commits from fix/registry-rows-err-check into staging
3 changed files with 21 additions and 15 deletions
@@ -407,15 +407,6 @@ func validateCallerToken(ctx context.Context, c *gin.Context, callerID string) e
// matching (the wsauth errors are typed for the invalid case).
var errInvalidCallerToken = errors.New("missing caller auth token")
// canvasUserMessage holds the extracted user message extracted from an
// A2A canvas request body for broadcasting to other sessions.
type canvasUserMessage struct {
Message string `json:"message,omitempty"`
Parts []map[string]interface{} `json:"parts,omitempty"`
MessageID string `json:"messageId,omitempty"`
Attachments []map[string]interface{} `json:"attachments,omitempty"`
}
// extractCanvasUserMessage parses an A2A JSON-RPC request body and extracts
// the user-authored text and attachments from a canvas-initiated message/send.
// Returns nil when the body is not a canvas user message (empty, malformed,
@@ -89,9 +89,14 @@ func sweepOnlineWorkspaces(ctx context.Context, checker ContainerChecker, onOffl
var ids []string
for rows.Next() {
var id string
if err := rows.Scan(&id); err == nil {
ids = append(ids, id)
if err := rows.Scan(&id); err != nil {
log.Printf("Health sweep: scan error: %v", err)
continue
}
ids = append(ids, id)
}
if err := rows.Err(); err != nil {
log.Printf("Health sweep: rows error: %v", err)
}
for _, id := range ids {
@@ -155,9 +160,14 @@ func sweepStaleRemoteWorkspaces(ctx context.Context, onOffline OfflineHandler) {
var ids []string
for rows.Next() {
var id string
if err := rows.Scan(&id); err == nil {
ids = append(ids, id)
if err := rows.Scan(&id); err != nil {
log.Printf("Health sweep (remote): scan error: %v", err)
continue
}
ids = append(ids, id)
}
if err := rows.Err(); err != nil {
log.Printf("Health sweep (remote): rows error: %v", err)
}
for _, id := range ids {
@@ -162,9 +162,14 @@ func sweepStuckProvisioning(ctx context.Context, emitter ProvisionTimeoutEmitter
var ids []candidate
for rows.Next() {
var c candidate
if err := rows.Scan(&c.id, &c.runtime, &c.ageSec); err == nil {
ids = append(ids, c)
if err := rows.Scan(&c.id, &c.runtime, &c.ageSec); err != nil {
log.Printf("Provision timeout: scan error: %v", err)
continue
}
ids = append(ids, c)
}
if err := rows.Err(); err != nil {
log.Printf("Provision timeout: rows error: %v", err)
}
for _, c := range ids {