Billionmail/BillionMail · error

failed to get all mailboxes: %w

Error message

failed to get all mailboxes: %w

What it means

GetAllMailbox wraps any error from mail_boxes.All(ctx, req.Domain) with this message. Like GetAllEmail, the failure is delegated to the service/DAO layer, so this error indicates the mailbox listing query failed (DB issue), not invalid input.

Source

Thrown at core/internal/controller/mail_boxes/mail_boxes_v1_get_all_mailbox.go:17

package mail_boxes

import (
	"billionmail-core/api/mail_boxes/v1"
	"billionmail-core/internal/service/mail_boxes"
	"billionmail-core/internal/service/public"
	"context"
	"fmt"
)

func (c *ControllerV1) GetAllMailbox(ctx context.Context, req *v1.GetAllMailboxReq) (res *v1.GetAllMailboxRes, err error) {
	res = &v1.GetAllMailboxRes{}

	res.Data, err = mail_boxes.All(ctx, req.Domain)

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

	res.SetSuccess(public.LangCtx(ctx, "Success"))

	return
}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Inspect the wrapped error from mail_boxes.All for the root cause.
  2. Check PostgreSQL health and connection pool usage.
  3. Confirm the domain exists if the service layer errors on unknown domains, then retry.
Defensive patterns

Strategy: retry

Validate before calling

if err := db.PingContext(ctx); err != nil {
    return fmt.Errorf("database unreachable, skip GetAllMailbox: %w", err)
}

Try / catch

data, err := api.getAllMailbox(domain)
if err != nil && strings.Contains(err.Error(), "failed to get all mailboxes") {
    return retryWithBackoff(3, func() error { _, err = api.getAllMailbox(domain); return err })
}

Prevention

When it happens

Trigger: Calling GetAllMailbox while the database is unavailable, schema is outdated, or the underlying mailbox query fails for the requested domain.

Common situations: DB connection limits reached; missing migration; replica lag or failover in progress.

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/e8ebcaa553e068cd. Report an issue: GitHub.