{"record":{"id":"52b6bbdbd67b010c","repo":"testcontainers/testcontainers-java","slug":"cannot-override-password-for-default-client","errorCode":null,"errorMessage":"Cannot override password for default client","messagePattern":"Cannot override password for default client","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/solace/src/main/java/org/testcontainers/solace/SolaceContainer.java","lineNumber":129,"sourceCode":"            updateConfigScript(scriptBuilder, \"create message-vpn \" + vpn);\n            updateConfigScript(scriptBuilder, \"no shutdown\");\n            updateConfigScript(scriptBuilder, \"exit\");\n            updateConfigScript(scriptBuilder, \"client-profile default message-vpn \" + vpn);\n            updateConfigScript(scriptBuilder, \"message-spool\");\n            updateConfigScript(scriptBuilder, \"allow-guaranteed-message-send\");\n            updateConfigScript(scriptBuilder, \"allow-guaranteed-message-receive\");\n            updateConfigScript(scriptBuilder, \"allow-guaranteed-endpoint-create\");\n            updateConfigScript(scriptBuilder, \"allow-guaranteed-endpoint-create-durability all\");\n            updateConfigScript(scriptBuilder, \"exit\");\n            updateConfigScript(scriptBuilder, \"exit\");\n            updateConfigScript(scriptBuilder, \"message-spool message-vpn \" + vpn);\n            updateConfigScript(scriptBuilder, \"max-spool-usage 60000\");\n            updateConfigScript(scriptBuilder, \"exit\");\n        }\n\n        // Configure username and password\n        if (username.equals(DEFAULT_USERNAME)) {\n            throw new RuntimeException(\"Cannot override password for default client\");\n        }\n        updateConfigScript(scriptBuilder, \"create client-username \" + username + \" message-vpn \" + vpn);\n        updateConfigScript(scriptBuilder, \"password \" + password);\n        updateConfigScript(scriptBuilder, \"no shutdown\");\n        updateConfigScript(scriptBuilder, \"exit\");\n\n        if (withClientCert) {\n            // Client certificate authority configuration\n            updateConfigScript(scriptBuilder, \"authentication\");\n            updateConfigScript(scriptBuilder, \"create client-certificate-authority RootCA\");\n            updateConfigScript(scriptBuilder, \"certificate file rootCA.crt\");\n            updateConfigScript(scriptBuilder, \"show client-certificate-authority ca-name *\");\n            updateConfigScript(scriptBuilder, \"end\");\n\n            // Server certificates configuration\n            updateConfigScript(scriptBuilder, \"configure\");\n            updateConfigScript(scriptBuilder, \"ssl\");\n            updateConfigScript(scriptBuilder, \"server-certificate solace.pem\");","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/solace/src/main/java/org/testcontainers/solace/SolaceContainer.java#L111-L147","documentation":"SolaceContainer builds a CLI configuration script at startup that creates a client username. The default client username's password is baked into the broker image and cannot be changed via this script, so if you call withUsername/withPassword trying to override the password while keeping the default username, createConfigurationScript throws RuntimeException 'Cannot override password for default client'.","triggerScenarios":"Calling container.withUsername(DEFAULT_USERNAME) (default 'default') while supplying a different password via withPassword, which reaches createConfigurationScript during configure().","commonSituations":"Tests wanting to keep the well-known default user but rotate its password; copying config code that sets both username and password unconditionally; environment-injected credentials where username happens to equal 'default'.","solutions":["Keep the default username with its default password and only use withPassword together with a non-default username.","Create a new non-default client username via withUsername(\"myuser\").withPassword(\"mypass\").","If default credentials are required, remove the withPassword call so no password override is attempted.","Check where username/password come from (config/env) and guard against username == 'default' with a custom password."],"exampleFix":"// before\ncontainer.withUsername(\"default\").withPassword(\"newSecret\"); // throws\n// after\ncontainer.withUsername(\"myuser\").withPassword(\"newSecret\");","handlingStrategy":"validation","validationCode":"static void validateSolaceCredentials(String username, String password) {\n  if (\"default\".equals(username) && password != null && !password.isBlank())\n    throw new IllegalArgumentException(\"Cannot override password for the default Solace client; use a custom username\");\n}\n// validateSolaceCredentials(container.getUsername(), myPassword);","typeGuard":null,"tryCatchPattern":"try {\n  container.withUsername(user).withPassword(pwd);\n  container.start();\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Cannot override password\")) {\n    throw new ConfigurationException(\"Use a non-default username to set a custom Solace password\"); }\n  throw e;\n}","preventionTips":["Never combine username 'default' with a custom password","Centralize Solace credential setup in one helper with this guard","Source credentials from config that distinguishes default vs custom users"],"tags":["solace","credentials","message-broker","illegal-state"],"backgroundTag":"conflicting-config-options","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"}