{"record":{"id":"96c526ba863038e8","repo":"netbirdio/netbird","slug":"password-must-be-at-least-8-characters-long","errorCode":null,"errorMessage":"password must be at least 8 characters long","messagePattern":"password must be at least 8 characters long","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"management/server/user.go","lineNumber":1914,"sourceCode":"\n\treturn nil\n}\n\nconst minPasswordLength = 8\n\n// validatePassword checks password strength requirements.\nfunc validatePassword(password string) error {\n\treturn ValidatePassword(password)\n}\n\n// ValidatePassword checks password strength requirements:\n// - Minimum 8 characters\n// - At least 1 digit\n// - At least 1 uppercase letter\n// - At least 1 special character\nfunc ValidatePassword(password string) error {\n\tif len(password) < minPasswordLength {\n\t\treturn errors.New(\"password must be at least 8 characters long\")\n\t}\n\n\tvar hasDigit, hasUpper, hasSpecial bool\n\tfor _, c := range password {\n\t\tswitch {\n\t\tcase unicode.IsDigit(c):\n\t\t\thasDigit = true\n\t\tcase unicode.IsUpper(c):\n\t\t\thasUpper = true\n\t\tcase !unicode.IsLetter(c) && !unicode.IsDigit(c):\n\t\t\thasSpecial = true\n\t\t}\n\t}\n\n\tvar missing []string\n\tif !hasDigit {\n\t\tmissing = append(missing, \"one digit\")\n\t}","sourceCodeStart":1896,"sourceCodeEnd":1932,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/management/server/user.go#L1896-L1932","documentation":"Returned by ValidatePassword (management/server/user.go:1914): the password must be at least minPasswordLength (8) characters. It is the first of four strength rules (length, digit, uppercase, special character) checked when a password is set for a user, e.g. during user creation or password update flows that call validatePassword.","triggerScenarios":"Any management call that sets a password with fewer than 8 characters, for example \"netbird\" or \"1234\".","commonSituations":"Test/seed scripts with throwaway passwords; password generators configured below 8 chars; users pasting a truncated password.","solutions":["Use a password of 8+ characters that also satisfies the remaining rules (1 digit, 1 uppercase, 1 special character)","Generate with a password manager or a generator that guarantees all four classes"],"exampleFix":"// before\npassword := \"netbird\"\n\n// after\npassword := \"Netbird!2026\"","handlingStrategy":"validation","validationCode":"const minPasswordLength = 8\n\nif len(password) < minPasswordLength {\n    return fmt.Errorf(\"password must be at least %d characters\", minPasswordLength)\n}","typeGuard":null,"tryCatchPattern":"if err := management.ValidatePassword(pw); err != nil {\n    if strings.Contains(err.Error(), \"at least 8 characters\") {\n        // reject in the form before any API call\n    }\n    return err\n}","preventionTips":["Enforce min length 8 plus all character classes in client-side validation and password managers","Use generators (e.g. 16+ chars with digits/upper/special) for seeded and service accounts","Call management.ValidatePassword directly if you import the package; otherwise mirror its rules"],"tags":["management","users","password","validation","security"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}