{"record":{"id":"19372d8c33032724","repo":"testcontainers/testcontainers-java","slug":"password-cannot-be-null-or-empty","errorCode":null,"errorMessage":"Password cannot be null or empty","messagePattern":"Password cannot be null or empty","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/oracle-free/src/main/java/org/testcontainers/oracle/OracleContainer.java","lineNumber":142,"sourceCode":"        return usingSid;\n    }\n\n    @Override\n    public OracleContainer withUsername(String username) {\n        if (StringUtils.isEmpty(username)) {\n            throw new IllegalArgumentException(\"Username cannot be null or empty\");\n        }\n        if (ORACLE_SYSTEM_USERS.contains(username.toLowerCase())) {\n            throw new IllegalArgumentException(\"Username cannot be one of \" + ORACLE_SYSTEM_USERS);\n        }\n        this.username = username;\n        return self();\n    }\n\n    @Override\n    public OracleContainer withPassword(String password) {\n        if (StringUtils.isEmpty(password)) {\n            throw new IllegalArgumentException(\"Password cannot be null or empty\");\n        }\n        this.password = password;\n        return self();\n    }\n\n    @Override\n    public OracleContainer withDatabaseName(String databaseName) {\n        if (StringUtils.isEmpty(databaseName)) {\n            throw new IllegalArgumentException(\"Database name cannot be null or empty\");\n        }\n\n        if (DEFAULT_DATABASE_NAME.equals(databaseName.toLowerCase())) {\n            throw new IllegalArgumentException(\"Database name cannot be set to \" + DEFAULT_DATABASE_NAME);\n        }\n\n        this.databaseName = databaseName;\n        return self();\n    }","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/oracle-free/src/main/java/org/testcontainers/oracle/OracleContainer.java#L124-L160","documentation":"OracleContainer.withPassword() validates that the password is non-null and non-empty before storing it. An IllegalArgumentException is thrown because Oracle connections require a password and the container builds JDBC URLs and wait logic from it.","triggerScenarios":"Calling withPassword(null), withPassword(\"\"), or withPassword(\" \").","commonSituations":"Passwords read from env vars or secrets that are missing in CI; placeholder resolution producing blank values.","solutions":["Pass a non-empty password string meeting Oracle's password policy.","Verify the secrets/env source actually provides the value.","Omit the call to rely on the container's default password if acceptable."],"exampleFix":"// before\ncontainer.withPassword(System.getenv(\"ORACLE_PASS\")); // may be null\n// after\nString pass = System.getenv(\"ORACLE_PASS\");\nif (pass == null || pass.isEmpty()) { pass = \"testpassword\"; }\ncontainer.withPassword(pass);","handlingStrategy":"validation","validationCode":"if (password == null || password.trim().isEmpty()) {\n    password = \"testpassword\"; // default before calling withPassword\n}","typeGuard":null,"tryCatchPattern":"try {\n    container.withPassword(password);\n} catch (IllegalArgumentException e) {\n    container.withPassword(\"testpassword\");\n}","preventionTips":["Check secret/env sources for presence before passing values in.","Centralize Oracle container defaults in a factory method.","Use test profiles that guarantee non-empty credentials."],"tags":["oracle","validation","credentials"],"backgroundTag":"empty-required-field","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}