{"record":{"id":"4e28b4385be7084c","repo":"Billionmail/BillionMail","slug":"failed-to-create-any-mailbox","errorCode":null,"errorMessage":"Failed to create any mailbox","messagePattern":"Failed to create any mailbox","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/mail_boxes/mail_boxes.go","lineNumber":371,"sourceCode":"\t\t\t\t\t_ = ensureMaildirAndQuotaFile(context.Background(), &mb)\n\t\t\t\t}(mb)\n\t\t\t}\n\n\t\t\tfor i := 0; i < cap(sem); i++ {\n\t\t\t\tsem <- struct{}{}\n\t\t\t}\n\t\t}(mailboxes)\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\n\t\treturn nil, fmt.Errorf(\"Failed to create email: %w\", err)\n\t}\n\n\tif len(emailList) == 0 {\n\t\treturn nil, fmt.Errorf(\"Failed to create any mailbox\")\n\t}\n\n\treturn emailList, nil\n}\n\n// AddImport\nfunc AddImport(ctx context.Context, mailbox *v1.Mailbox) (err error) {\n\n\tif mailbox.PasswordEncode != \"\" {\n\n\t\tif mailbox.Password == \"\" {\n\t\t\tmailbox.Password, err = PasswdDecode(ctx, mailbox.PasswordEncode)\n\t\t\tif err != nil {\n\t\t\t\terr = fmt.Errorf(\"Decode password failed: %w\", err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tmailbox.Password, err = PasswdMD5Crypt(ctx, mailbox.Password)","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/mail_boxes/mail_boxes.go#L353-L389","documentation":"Thrown by BatchAdd when the transaction succeeded but the collected emailList is empty, meaning zero mailboxes were actually created despite the request. It guards against silently returning success with no results, typically caused by all rows being ignored by InsertIgnore (e.g. all duplicates).","triggerScenarios":"BatchAddMailbox where InsertIgnore skipped every row (all generated emails already exist) or the email generation produced no entries.","commonSituations":"Re-running the same batch request with identical prefixes/counts so every generated address collides with existing mailboxes; off-by-one or empty count inputs.","solutions":["Check whether the target mailboxes already exist; use unique prefixes or new usernames","Verify the count parameter passed to BatchAddMailbox is > 0","Inspect emailList generation logic if prefixes are dynamic but yield duplicates"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if count <= 0 { return errors.New(\"count must be positive\") }\nif prefix == \"\" { return errors.New(\"prefix is required\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate count > 0 and a fresh prefix before each batch call","Avoid re-running identical batch requests; change prefix or clean up first","Check for existing mailboxes to prevent all-duplicate InsertIgnore outcomes"],"tags":["go","validation","batch","empty-result"],"backgroundTag":"batch-operation-no-results","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"}