Billionmail/BillionMail · error

failed to get task info: %w

Error message

failed to get task info: %w

What it means

GetTaskInfo reads a single row from email_tasks (including tag_ids aliased as TagIdsRaw) and returns it. Any database error during the scan is wrapped as "failed to get task info: %w". Note that Scan into a struct typically does not error when no row matches — callers should also handle a zero-value task; this error specifically means the query itself failed.

Source

Thrown at core/internal/service/batch_mail/batch_mail.go:531

		return nil
	})
	if err != nil {
		return 0, err
	}

	return taskId, nil
}

// GetTaskInfo get task info
func GetTaskInfo(ctx context.Context, taskId int) (*entity.EmailTask, error) {
	var task entity.EmailTask
	err := g.DB().Model("email_tasks").
		Where("id", taskId).
		Fields("*, tag_ids as TagIdsRaw").
		Scan(&task)

	if err != nil {
		return nil, fmt.Errorf("failed to get task info: %w", err)
	}

	return &task, nil
}

// UpdateTaskPauseStatus update task pause status
func UpdateTaskPauseStatus(ctx context.Context, taskId int, isPaused bool) error {
	pauseValue := 0
	processValue := 1

	if isPaused {
		pauseValue = 1
		processValue = 3
	}

	_, err := g.DB().Model("email_tasks").
		Where("id", taskId).
		Data(g.Map{

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Check the wrapped underlying error and PostgreSQL health
  2. Verify email_tasks schema includes tag_ids and matches the entity (run migrations)
  3. Confirm DB user SELECT permissions on email_tasks
  4. Retry after restoring connectivity; add backoff in callers that poll task info
Defensive patterns

Strategy: try-catch

Validate before calling

if taskId <= 0 {
    return errors.New("invalid taskId")
}

Try / catch

task, err := GetTaskInfo(ctx, taskId)
if err != nil {
    if strings.Contains(err.Error(), "failed to get task info") {
        // check DB health, then surface a 503/retry to the caller
    }
    return err
}
if task.Id == 0 {
    return ErrTaskNotFound // distinguish empty result from DB failure
}

Prevention

When it happens

Trigger: Any of DeleteTask, GetTaskMailLogs, GetTaskSendCount, PauseTask, ResumeTask, TaskInfo invoking GetTaskInfo while the SELECT on email_tasks fails: DB unreachable, connection pool exhausted, permission denied, schema drift (missing tag_ids column), or a timeout on a locked table.

Common situations: Postgres down or restarting while the UI polls task status; migration removed/renamed tag_ids; DB user lacks SELECT on email_tasks; heavy lock contention from bulk task updates.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/a97382f42a24a860. Report an issue: GitHub.