{"record":{"id":"61f21f980650232d","repo":"Billionmail/BillionMail","slug":"admin-username-can-only-contain-letters-numbers-a","errorCode":null,"errorMessage":"admin username can only contain letters, numbers and underscores","messagePattern":"admin username can only contain letters, numbers and underscores","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/controller/settings/settings.go","lineNumber":197,"sourceCode":"\t}\n\treturn defaultValue\n}\n\n// validateConfigValue\nfunc validateConfigValue(key, value string) error {\n\t// Basic length check\n\tif len(value) > 1024 {\n\t\treturn fmt.Errorf(\"configuration value too long, maximum 1024 characters\")\n\t}\n\n\tswitch key {\n\tcase \"ADMIN_USERNAME\", \"admin_username\":\n\t\t// Admin username: allowed letters, numbers, underscores, length 4-32\n\t\tif len(value) < 4 || len(value) > 32 {\n\t\t\treturn fmt.Errorf(\"admin username length must be between 4-32\")\n\t\t}\n\t\tif !public.IsValidUsername(value) {\n\t\t\treturn fmt.Errorf(\"admin username can only contain letters, numbers and underscores\")\n\t\t}\n\n\tcase \"ADMIN_PASSWORD\", \"admin_password\":\n\t\tif len(value) < 4 {\n\t\t\treturn fmt.Errorf(\"password length must be at least 4 characters\")\n\t\t}\n\n\tcase \"BILLIONMAIL_HOSTNAME\", \"billionmail_hostname\":\n\t\t// Hostname: allowed letters, numbers, dots, hyphens\n\t\tif !public.IsValidHostname(value) {\n\t\t\treturn fmt.Errorf(\"hostname format is incorrect\")\n\t\t}\n\n\tcase \"SMTP_PORT\", \"SMTPS_PORT\", \"SUBMISSION_PORT\", \"IMAP_PORT\", \"IMAPS_PORT\", \"POP_PORT\", \"POPS_PORT\", \"HTTP_PORT\", \"HTTPS_PORT\", \"REDIS_PORT\",\n\t\t\"smtp\", \"smtps\", \"submission\", \"imap\", \"imaps\", \"pop\", \"pops\", \"http\", \"https\", \"redis_port\":\n\t\t// Port: 1-65535\n\t\tport := public.ParseInt(value)\n\t\tif port < 1 || port > 65535 {","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/settings/settings.go#L179-L215","documentation":"After the length check, ADMIN_USERNAME values must pass public.IsValidUsername, which permits only letters, numbers and underscores. Any other character (spaces, hyphens, dots, email '@', unicode) triggers this error.","triggerScenarios":"SetSystemConfig with ADMIN_USERNAME containing characters outside [A-Za-z0-9_], e.g. 'john.doe', 'admin user', 'ops-admin', or 'user@example.com'.","commonSituations":"Using an email address as the admin username; names with spaces or dots; copy-paste including invisible whitespace or unicode characters.","solutions":["Replace invalid characters with underscores, e.g. 'john.doe' -> 'john_doe'","Use only letters, numbers and underscores in the username","Trim leading/trailing whitespace and strip invisible characters before submitting","Store the email address in a separate email config/account field"],"exampleFix":"// before\nsetConfig(\"ADMIN_USERNAME\", \"john.doe@example.com\")\n// after\nsetConfig(\"ADMIN_USERNAME\", \"john_doe\")","handlingStrategy":"validation","validationCode":"function isValidUsernameChars(u) {\n  return typeof u === 'string' && /^[A-Za-z0-9_]{4,32}$/.test(u);\n}","typeGuard":"function isPlainUsername(v: unknown): v is string {\n  return typeof v === 'string' && /^[A-Za-z0-9_]{4,32}$/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Restrict the username input to letters, numbers, underscores","Normalize dots/hyphens to underscores before submit","Strip invisible/unicode characters on paste","Mirror the server regex client-side"],"tags":["validation","admin","username","settings"],"backgroundTag":"config-value-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"}