fix(delegation): add rows.Err() check and fix discarded ExecContext error #2038

Closed
core-be wants to merge 2 commits from fix/delegation-rows-err-check into staging
2 changed files with 7 additions and 11 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,
@@ -242,10 +242,12 @@ func lookupIdempotentDelegation(ctx context.Context, c *gin.Context, sourceID, i
return false
}
if existingStatus == "failed" {
_, _ = db.DB.ExecContext(ctx, `
if _, err := db.DB.ExecContext(ctx, `
DELETE FROM activity_logs
WHERE workspace_id = $1 AND idempotency_key = $2 AND status = 'failed'
`, sourceID, idempotencyKey)
`, sourceID, idempotencyKey); err != nil {
log.Printf("Delegation: failed to clean up failed idempotent row for %s/%s: %v", sourceID, idempotencyKey, err)
}
return false
}
c.JSON(http.StatusOK, gin.H{
@@ -828,6 +830,9 @@ func (h *DelegationHandler) listDelegationsFromActivityLogs(ctx context.Context,
if err := rows.Err(); err != nil {
log.Printf("ListDelegations rows.Err: %v", err)
}
if err := rows.Err(); err != nil {
log.Printf("delegation list rows error: %v", err)
}
if result == nil {
return []map[string]interface{}{}