{"record":{"id":"14cd082610740ed1","repo":"Billionmail/BillionMail","slug":"prefix-validation-error-w","errorCode":null,"errorMessage":"Prefix validation error: %w","messagePattern":"Prefix validation error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/mail_boxes/mail_boxes.go","lineNumber":255,"sourceCode":"\tfor i := range password {\n\t\tpassword[i] = charset[rand.Intn(len(charset))]\n\t}\n\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)","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/mail_boxes/mail_boxes.go#L237-L273","documentation":"Thrown by BatchAdd when regexp.MatchString fails while validating the mailbox prefix against ^[\\w-]+$. MatchString only errors on an invalid regular expression, which here is a compile-time constant, so in practice this error is nearly unreachable and always indicates an internal/regexp-engine problem rather than bad user input.","triggerScenarios":"Calling BatchAddMailbox (via BatchAdd) and the Go regexp engine fails to compile/match the hard-coded pattern ^[\\w-]+$ during prefix validation.","commonSituations":"Extremely rare; could occur with a corrupted Go installation, a modified copy of the code where the pattern string is built dynamically and contains invalid regex syntax, or exotic regexp-engine edge cases.","solutions":["Confirm the regex literal ^[\\w-]+$ in mail_boxes.go was not modified to an invalid pattern","Check the wrapped error from %w for the exact regexp compile message","Rebuild/redeploy the binary with an unmodified, supported Go toolchain"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"Prefix validation error\") {\n    // internal regexp failure: report as a bug, do not retry blindly\n}","preventionTips":["Run production builds with a standard supported Go toolchain","Do not modify the hard-coded validation regex","Treat occurrences of this error as an internal defect report"],"tags":["go","regex","validation"],"backgroundTag":"invalid-regex-pattern","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"}