{"record":{"id":"a10efe42c12db69a","repo":"testcontainers/testcontainers-java","slug":"password-must-contain-characters-from-three-of-the-following","errorCode":null,"errorMessage":"Password must contain characters from three of the following four categories:\n - Latin uppercase letters (A through Z)\n - Latin lowercase letters (a through z)\n - Base 10 digits (0 through 9)\n - Non-alphanumeric characters such as: exclamation point (!), dollar sign ($), number sign (#), or percent (%).","messagePattern":"Password must contain characters from three of the following four categories:\n - Latin uppercase letters \\(A through Z\\)\n - Latin lowercase letters \\(a through z\\)\n - Base 10 digits \\(0 through 9\\)\n - Non-alphanumeric characters such as: exclamation point \\(!\\), dollar sign \\(\\$\\), number sign \\(#\\), or percent \\(%\\)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainer.java","lineNumber":159,"sourceCode":"        if (password == null) {\n            throw new IllegalArgumentException(\"Null password is not allowed\");\n        }\n\n        if (password.length() < 8) {\n            throw new IllegalArgumentException(\"Password should be at least 8 characters long\");\n        }\n\n        if (password.length() > 128) {\n            throw new IllegalArgumentException(\"Password can be up to 128 characters long\");\n        }\n\n        long satisfiedCategories = Stream\n            .of(PASSWORD_CATEGORY_VALIDATION_PATTERNS)\n            .filter(p -> p.matcher(password).find())\n            .count();\n\n        if (satisfiedCategories < 3) {\n            throw new IllegalArgumentException(\n                \"Password must contain characters from three of the following four categories:\\n\" +\n                \" - Latin uppercase letters (A through Z)\\n\" +\n                \" - Latin lowercase letters (a through z)\\n\" +\n                \" - Base 10 digits (0 through 9)\\n\" +\n                \" - Non-alphanumeric characters such as: exclamation point (!), dollar sign ($), number sign (#), \" +\n                \"or percent (%).\"\n            );\n        }\n    }\n}\n","sourceCodeStart":141,"sourceCodeEnd":170,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainer.java#L141-L170","documentation":"SQL Server requires the sa password to include characters from at least three of four categories: uppercase, lowercase, digits, and non-alphanumeric symbols. testcontainers pre-validates this with regex patterns in checkPasswordStrength() so misconfiguration fails fast instead of at container startup.","triggerScenarios":"Calling withPassword() with an 8+ character password composed of fewer than three character categories, e.g. \"abcdefgh\" or \"12345678\".","commonSituations":"Using alphabetic-only or digit-only test passwords; secrets generated with limited character sets; users unaware SQL Server enforces complexity policy.","solutions":["Add characters from a third category (e.g. append \"!\" or mix case and digits)","Use a known-good password like \"yourStrong(!)Password\"","Pre-validate the password against the 3-of-4 category rule in test setup"],"exampleFix":"// before\ncontainer.withPassword(\"abcdefgh\"); // only lowercase\n// after\ncontainer.withPassword(\"Abcdefg1!\"); // upper + lower + digit + symbol","handlingStrategy":"validation","validationCode":"boolean strong = password != null\n    && password.matches(\".*[A-Z].*\")\n    && password.matches(\".*[a-z].*\")\n    && password.matches(\".*[0-9].*\")\n    && password.matches(\".*[^A-Za-z0-9].*\");\nif (!strong) throw new IllegalArgumentException(\"Password needs 3 of 4 character categories\");","typeGuard":null,"tryCatchPattern":"try { container.withPassword(pw); } catch (IllegalArgumentException e) { throw new IllegalStateException(\"SA password fails SQL Server complexity policy: \" + e.getMessage(), e); }","preventionTips":["Keep a canonical test password constant like \"yourStrong(!)Password\"","Remember SQL Server enforces complexity policy — never use alphabetic-only passwords in tests"],"tags":["testcontainers","mssql","password","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}