diff --git a/internal/adapter/postgres/work_queue.go b/internal/adapter/postgres/work_queue.go index d0cdbff..c14a731 100644 --- a/internal/adapter/postgres/work_queue.go +++ b/internal/adapter/postgres/work_queue.go @@ -60,9 +60,11 @@ func (r *WorkQueueRepository) Dequeue(ctx context.Context, workerID string) (*do var resultJSON []byte var errorMsg sql.NullString + // Clear stale error/completed_at when claiming for execution or retry. + // This prevents the API from returning confusing "running" status with stale error messages. err := r.db.QueryRowContext(ctx, ` UPDATE work_queue - SET status = 'running', worker_id = $1, started_at = NOW() + SET status = 'running', worker_id = $1, started_at = NOW(), error = NULL, completed_at = NULL WHERE id = ( SELECT id FROM work_queue WHERE status = 'pending'