{"record":{"id":"91b968cc929a6bba","repo":"Billionmail/BillionMail","slug":"prefixes-can-contain-only-letters-numbers-unders","errorCode":null,"errorMessage":"Prefixes can contain only letters, numbers, underscores, and hyphens","messagePattern":"Prefixes can contain only letters, numbers, underscores, and hyphens","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/mail_boxes/mail_boxes.go","lineNumber":258,"sourceCode":"\treturn string(password)\n}\nfunc BatchAdd(ctx context.Context, domain string, quota int, count int, prefix string, quotaActive int) ([]string, error) {\n\n\tif prefix == \"\" {\n\t\trandomPre := make([]byte, 4)\n\t\tfor j := 0; j < 4; j++ {\n\t\t\trandomPre[j] = byte(rand.Intn(26) + 97) // a-z的ASCII码\n\t\t}\n\n\t\tprefix = string(randomPre)\n\t}\n\n\tmatched, err := regexp.MatchString(`^[\\w-]+$`, prefix)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Prefix validation error: %w\", err)\n\t}\n\tif !matched {\n\t\treturn nil, fmt.Errorf(\"Prefixes can contain only letters, numbers, underscores, and hyphens\")\n\t}\n\n\trand.Seed(time.Now().UnixNano())\n\n\tcreatedEmails := make([]string, 0, count)\n\n\ttimestamp := time.Now().Unix()\n\n\t//passwordEncoded := PasswdEncode(ctx, password)\n\t//passwordCrypted, err := PasswdMD5Crypt(ctx, password)\n\t//if err != nil {\n\t//\treturn nil, fmt.Errorf(\"Generate password md5-crypt failed: %w\", err)\n\t//}\n\n\tmailboxes := make([]v1.Mailbox, 0, count)\n\temailList := make([]string, 0, count)\n\n\tfor i := 0; i < count; i++ {","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/mail_boxes/mail_boxes.go#L240-L276","documentation":"A domain-validation error thrown by BatchAdd when the requested mailbox prefix contains characters outside letters, digits, underscores, and hyphens. The prefix is used to generate batch mailbox local-parts, so invalid characters would produce unusable email addresses. This is an input validation error, not an internal failure.","triggerScenarios":"Calling BatchAddMailbox with a prefix such as 'team@', 'my prefix', 'café', or an empty/symbol-only string that fails the ^[\\w-]+$ check (note Go's \\w is ASCII-only).","commonSituations":"Users entering prefixes with spaces, '@', dots, or non-ASCII/accented characters in batch mailbox creation forms or API calls.","solutions":["Resend the request with a prefix containing only A-Z, a-z, 0-9, '_' and '-'","Strip or transliterate non-ASCII characters from the prefix before calling BatchAdd","If you need dots or other characters in addresses, create mailboxes individually rather than via BatchAdd"],"exampleFix":"// before\nprefix := \"sales team\"\nBatchAddMailbox(..., prefix, count)\n// after\nprefix := \"sales-team\"\nBatchAddMailbox(..., prefix, count)","handlingStrategy":"validation","validationCode":"var prefixRe = regexp.MustCompile(`^[\\w-]+$`)\nif !prefixRe.MatchString(prefix) {\n    return errors.New(\"prefix must contain only letters, numbers, underscores, hyphens\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Sanitize prefixes client-side before calling BatchAdd","Reject non-ASCII and whitespace in prefix inputs in the UI","Document the allowed prefix characters in your API docs"],"tags":["go","validation","input"],"backgroundTag":"schema-validation-failed","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}