{"record":{"id":"af270e1fc70d8c49","repo":"Billionmail/BillionMail","slug":"failed-to-get-all-emails-w","errorCode":null,"errorMessage":"failed to get all emails: %w","messagePattern":"failed to get all emails: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/controller/mail_boxes/mail_boxes_v1_get_all_email.go","lineNumber":18,"sourceCode":"package mail_boxes\n\nimport (\n\t\"billionmail-core/internal/service/mail_boxes\"\n\t\"billionmail-core/internal/service/public\"\n\t\"context\"\n\t\"fmt\"\n\n\t\"billionmail-core/api/mail_boxes/v1\"\n)\n\nfunc (c *ControllerV1) GetAllEmail(ctx context.Context, req *v1.GetAllEmailReq) (res *v1.GetAllEmailRes, err error) {\n\tres = &v1.GetAllEmailRes{}\n\n\tres.Data, err = mail_boxes.AllEmail(ctx, req.Domain)\n\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed to get all emails: %w\", err)\n\t\treturn\n\t}\n\n\tres.SetSuccess(public.LangCtx(ctx, \"Success\"))\n\n\treturn\n}\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/mail_boxes/mail_boxes_v1_get_all_email.go#L1-L26","documentation":"GetAllEmail wraps any error returned by mail_boxes.AllEmail(ctx, req.Domain) with this message. AllEmail reads every email address for a domain, so the wrapped error is typically a database/query failure, not a client-input problem.","triggerScenarios":"Calling GetAllEmail when the database is unreachable, the mail_boxes table/schema is missing, or mail_boxes.AllEmail encounters a query error for the given domain.","commonSituations":"PostgreSQL down or connection pool exhausted; migration not applied; transient DB timeout during heavy load.","solutions":["Read the wrapped inner error to identify the actual DB failure.","Verify PostgreSQL connectivity and that migrations have run (mail_boxes tables exist).","Retry the request if the failure was transient (pool exhaustion, timeout)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Light pre-check: DB reachable before listing\nif err := db.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"database unreachable, skip GetAllEmail: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"data, err := api.getAllEmail(domain)\nif err != nil && strings.Contains(err.Error(), \"failed to get all emails\") {\n    // log the wrapped cause; retry with backoff for transient DB failures\n    return retryWithBackoff(3, func() error { _, err = api.getAllEmail(domain); return err })\n}","preventionTips":["Monitor PostgreSQL connectivity and pool saturation.","Run migrations before deploying API versions that query new tables.","Add client-side retry with backoff for listing endpoints."],"tags":["database","mailboxes","query"],"backgroundTag":"database-query-failed","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}