{"record":{"id":"237080a6b5a9892b","repo":"Billionmail/BillionMail","slug":"admin-username-length-must-be-between-4-32","errorCode":null,"errorMessage":"admin username length must be between 4-32","messagePattern":"admin username length must be between 4-32","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/controller/settings/settings.go","lineNumber":194,"sourceCode":"func parseInt(s string, defaultValue int) int {\n\tif v, err := strconv.Atoi(s); err == nil {\n\t\treturn v\n\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\":","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/settings/settings.go#L176-L212","documentation":"For the ADMIN_USERNAME key (case-insensitive), validateConfigValue enforces a length of 4-32 bytes. Values shorter than 4 or longer than 32 are rejected with this message before the username is persisted.","triggerScenarios":"SetSystemConfig/SetSystemConfigKey with key ADMIN_USERNAME/admin_username and a value of length <4 (e.g. 'ab') or >32 characters.","commonSituations":"Admin setups using very short usernames like 'adm'; machine-generated long usernames (email-like addresses) pasted as the admin username.","solutions":["Choose a username of 4-32 characters","Trim whitespace and check len(value) before calling the API","Use letters, numbers and underscores only (next validator also applies)","If you need a longer login name, use the email field rather than ADMIN_USERNAME"],"exampleFix":"// before\nsetConfig(\"ADMIN_USERNAME\", \"ab\") // rejected\n// after\nsetConfig(\"ADMIN_USERNAME\", \"admin\") // 4-32 chars","handlingStrategy":"validation","validationCode":"function isValidAdminUsername(u) {\n  return typeof u === 'string' && u.length >= 4 && u.length <= 32;\n}","typeGuard":"function isAdminUsername(v: unknown): v is string {\n  return typeof v === 'string' && v.length >= 4 && v.length <= 32;\n}","tryCatchPattern":null,"preventionTips":["Enforce 4-32 length in the admin form","Trim whitespace before submit","Avoid using emails as usernames","Add input maxLength=32 in the UI"],"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"}