Billionmail/BillionMail · critical
Failed to create email: %w
Error message
Failed to create email: %w
What it means
Top-level wrapper in BatchAdd: after the transaction closure runs, any error it returned is re-wrapped as 'Failed to create email: %w'. It indicates that the batch mailbox creation transaction did not complete — the real cause is always nested inside. If err is nil but nothing was created, error 325 is thrown instead.
Source
Thrown at core/internal/service/mail_boxes/mail_boxes.go:367
mb := mbs[i]
sem <- struct{}{}
go func(mb v1.Mailbox) {
defer func() { <-sem }()
_ = ensureMaildirAndQuotaFile(context.Background(), &mb)
}(mb)
}
for i := 0; i < cap(sem); i++ {
sem <- struct{}{}
}
}(mailboxes)
return nil
})
if err != nil {
return nil, fmt.Errorf("Failed to create email: %w", err)
}
if len(emailList) == 0 {
return nil, fmt.Errorf("Failed to create any mailbox")
}
return emailList, nil
}
// AddImport
func AddImport(ctx context.Context, mailbox *v1.Mailbox) (err error) {
if mailbox.PasswordEncode != "" {
if mailbox.Password == "" {
mailbox.Password, err = PasswdDecode(ctx, mailbox.PasswordEncode)
if err != nil {
err = fmt.Errorf("Decode password failed: %w", err)View on GitHub (pinned to fc36c76c05)
Solutions
- Unwrap the error to find the root cause (look for 'Batch insert mailbox failed' or similar)
- Fix the underlying database/transaction issue identified by the wrapped error
- Retry the batch creation after resolving the cause
Defensive patterns
Strategy: try-catch
Try / catch
created, err := BatchAddMailbox(...)
if err != nil {
var root = err
for errors.Unwrap(root) != nil { root = errors.Unwrap(root) }
log.Printf("batch create failed, root cause: %v", root)
} Prevention
- Always unwrap to the root cause before acting on this error
- Fix DB-level issues before retrying bulk creations
- Log the full error chain for diagnosis
When it happens
Trigger: Any failure inside the BatchAdd transaction (e.g. error 323 batch insert failure) surfacing at the BatchAddMailbox call boundary.
Common situations: Bulk mailbox provisioning failing because of database errors, constraint conflicts, or transaction aborts.
Related errors
- Batch insert mailbox failed (batch %d-%d): %w
- failed to import recipients (batch %d/%d): %w
- Failed to create any mailbox
- failed to get all domains: %w
- fail to check domain: %w
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/f43307f8d31e3426.
Report an issue: GitHub.