Billionmail/BillionMail · error
Failed to get the exception recipient list: %w
Error message
Failed to get the exception recipient list: %w
What it means
After counting, GetListWithPage fetches one page of abnormal recipients ordered by create_time DESC; a Scan failure is wrapped as 'Failed to get the exception recipient list'. Like the count error, this indicates a database read failure on the list query.
Source
Thrown at core/internal/service/abnormal_recipient/abnormal_recipient.go:42
if keyword != "" {
model = model.WhereLike("recipient", "%"+keyword+"%")
}
if addType > 0 {
model = model.Where("add_type", addType)
}
total, err = model.Count()
if err != nil {
return 0, nil, fmt.Errorf("Failed to get the total number of exception recipients: %w", err)
}
list = make([]*entity.AbnormalRecipient, 0)
err = model.Page(page, pageSize).
Order("create_time DESC").
Scan(&list)
if err != nil {
return 0, nil, fmt.Errorf("Failed to get the exception recipient list: %w", err)
}
return total, list, nil
}
func Add(ctx context.Context, recipient string) error {
now := time.Now().Unix()
_, err := g.DB().Model("abnormal_recipient").
Data(g.Map{
"recipient": recipient,
"count": 3,
"add_type": 1,
"description": "Manually added",
"create_time": now,
}).
InsertIgnore()
View on GitHub (pinned to fc36c76c05)
Solutions
- Inspect the wrapped %w error — 'sql: no rows' variants vs connection vs scan-type errors need different fixes.
- Run migrations to reconcile the entity.AbnormalRecipient struct with the actual table schema.
- Check DB connectivity and retry if the failure was transient.
- Compare entity field types against the table columns if the error mentions scan/conversion.
Example fix
// before
err = model.Page(page, pageSize).Order("create_time DESC").Scan(&list)
if err != nil { return 0, nil, fmt.Errorf("Failed to get the exception recipient list: %w", err) }
// after
if err := model.Page(page, pageSize).Order("create_time DESC").Scan(&list); err != nil {
return 0, nil, fmt.Errorf("Failed to get the exception recipient list (page=%d, size=%d): %w", page, pageSize, err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// validate pagination inputs before the call
if page < 1 || pageSize < 1 || pageSize > 500 {
return errors.New("invalid pagination parameters")
} Try / catch
total, list, err := abnormal_recipient.GetListWithPage(ctx, page, pageSize, addType)
if err != nil {
if isTransientDBError(err) { // timeouts, connection resets
return retryWithBackoff(3, func() error { _, _, err = GetListWithPage(...); return err })
}
return err
} Prevention
- Keep entity.AbnormalRecipient in sync with table schema via migrations
- Distinguish transient (retry) from permanent (schema) DB errors
- Clamp pageSize to reasonable bounds to avoid heavy scans
- Alert on DB error rates for list endpoints
When it happens
Trigger: ListAbnormalRecipient with valid pagination while the page/order Scan fails: DB unreachable, table missing, or row data that cannot be scanned into entity.AbnormalRecipient (schema/type mismatch after migration).
Common situations: Schema drift where a column type changed and scanning fails; transient connection drop between Count and Scan; missing table on a fresh environment; corrupted rows.
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
- Failed to get the total number of exception recipients: %w
- failed to get all emails: %w
- failed to get all mailboxes: %w
- failed to load API templates: %v
- failed to load email templates: %v
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/c16a0b53f72a3f07.
Report an issue: GitHub.