Billionmail/BillionMail · error
Prefixes can contain only letters, numbers, underscores, and
Error message
Prefixes can contain only letters, numbers, underscores, and hyphens
What it means
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.
Source
Thrown at core/internal/service/mail_boxes/mail_boxes.go:258
return string(password)
}
func BatchAdd(ctx context.Context, domain string, quota int, count int, prefix string, quotaActive int) ([]string, error) {
if prefix == "" {
randomPre := make([]byte, 4)
for j := 0; j < 4; j++ {
randomPre[j] = byte(rand.Intn(26) + 97) // a-z的ASCII码
}
prefix = string(randomPre)
}
matched, err := regexp.MatchString(`^[\w-]+$`, prefix)
if err != nil {
return nil, fmt.Errorf("Prefix validation error: %w", err)
}
if !matched {
return nil, fmt.Errorf("Prefixes can contain only letters, numbers, underscores, and hyphens")
}
rand.Seed(time.Now().UnixNano())
createdEmails := make([]string, 0, count)
timestamp := time.Now().Unix()
//passwordEncoded := PasswdEncode(ctx, password)
//passwordCrypted, err := PasswdMD5Crypt(ctx, password)
//if err != nil {
// return nil, fmt.Errorf("Generate password md5-crypt failed: %w", err)
//}
mailboxes := make([]v1.Mailbox, 0, count)
emailList := make([]string, 0, count)
for i := 0; i < count; i++ {View on GitHub (pinned to fc36c76c05)
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
Example fix
// before prefix := "sales team" BatchAddMailbox(..., prefix, count) // after prefix := "sales-team" BatchAddMailbox(..., prefix, count)
Defensive patterns
Strategy: validation
Validate before calling
var prefixRe = regexp.MustCompile(`^[\w-]+$`)
if !prefixRe.MatchString(prefix) {
return errors.New("prefix must contain only letters, numbers, underscores, hyphens")
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: Users entering prefixes with spaces, '@', dots, or non-ASCII/accented characters in batch mailbox creation forms or API calls.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- supplier name, base URL, and API key are required
- Add up to 3 URLs
- invalid base URL format: %w
- base URL must use http or https protocol
- empty token string
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/91b968cc929a6bba.
Report an issue: GitHub.