Billionmail/BillionMail · error
Failed to add exception recipient: %w
Error message
Failed to add exception recipient: %w
What it means
Add inserts a manually-added recipient into the abnormal_recipient table with InsertIgnore. When the underlying SQL INSERT fails (connection loss, schema mismatch, permission denial, driver error), the raw driver error is wrapped with this message and returned to the caller AddAbnormalRecipient.
Source
Thrown at core/internal/service/abnormal_recipient/abnormal_recipient.go:62
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()
if err != nil {
return fmt.Errorf("Failed to add exception recipient: %w", err)
}
return nil
}
func Delete(ctx context.Context, id int) error {
_, err := g.DB().Model("abnormal_recipient").
Where("id", id).
Delete()
if err != nil {
return fmt.Errorf("Failed to remove exception recipient: %w", err)
}
return nil
}
View on GitHub (pinned to fc36c76c05)
Solutions
- Verify the database is reachable and the abnormal_recipient table exists (run migrations).
- Unwrap the %w error to see the driver message (pq: relation "abnormal_recipient" does not exist, etc.) and fix accordingly.
- Check INSERT privileges for the configured DB user.
- Retry once on transient connection errors.
Example fix
// before
err := abnormal_recipient.Add(ctx, "user@example.com")
if err != nil { log.Print(err) }
// after
if err := public.EnsureAbnormalRecipientTable(ctx); err != nil { return err }
if err := abnormal_recipient.Add(ctx, "user@example.com"); err != nil {
return fmt.Errorf("add abnormal recipient: %w", err)
} Defensive patterns
Strategy: validation
Validate before calling
// before calling Add
if recipient == "" { return errors.New("recipient required") }
if !g.DB().TableFields("abnormal_recipient") { /* table missing -> run migrations first */ } Try / catch
if err := abnormal_recipient.Add(ctx, r); err != nil {
var gerr gerror.Error
if errors.As(err, &gerr) { logger.Error(ctx, gerr.Error()) }
return fmt.Errorf("add recipient: %w", err)
} Prevention
- Run migrations before starting the service
- Health-check the DB at startup
- Log the wrapped error with context (recipient, addType)
When it happens
Trigger: Calling Add(ctx, recipient) when the PostgreSQL server is unreachable, the abnormal_recipient table/columns are missing or renamed, or the DB user lacks INSERT privilege on the table.
Common situations: Fresh deployments where migrations have not created abnormal_recipient yet; docker-compose where the postgres container is not up; schema drift after an upgrade that renamed add_type/description columns.
Related errors
- Failed to insert abnormal recipients: %w
- Failed to remove exception recipient: %w
- Failed to get exception recipient: %w
- Failed to query existing abnormal recipients: %w
- Failed to update abnormal recipient: %w
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/7eef562acf307ede.
Report an issue: GitHub.