{"record":{"id":"f964bb1c5d890af3","repo":"apache/cassandra","slug":"username-provided-but-no-password","errorCode":null,"errorMessage":"Username provided but no password","messagePattern":"Username provided but no password","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"tools/fqltool/src/org/apache/cassandra/fqltool/QueryReplayer.java","lineNumber":215,"sourceCode":"        {\n            this.host = host;\n            this.port = port;\n            this.user = user;\n            this.password = password;\n        }\n\n        static ParsedTargetHost fromString(String s)\n        {\n            String [] userInfoHostPort = s.split(\"@\");\n\n            String hostPort = null;\n            String user = null;\n            String password = null;\n            if (userInfoHostPort.length == 2)\n            {\n                String [] userPassword = userInfoHostPort[0].split(\":\");\n                if (userPassword.length != 2)\n                    throw new RuntimeException(\"Username provided but no password\");\n                hostPort = userInfoHostPort[1];\n                user = userPassword[0];\n                password = userPassword[1];\n            }\n            else if (userInfoHostPort.length == 1)\n                hostPort = userInfoHostPort[0];\n            else\n                throw new RuntimeException(\"Malformed target host: \"+s);\n\n            String[] splitHostPort = hostPort.split(\":\");\n            int port = 9042;\n            if (splitHostPort.length == 2)\n                port = Integer.parseInt(splitHostPort[1]);\n\n            return new ParsedTargetHost(splitHostPort[0], port, user, password);\n        }\n    }\n","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/fqltool/src/org/apache/cassandra/fqltool/QueryReplayer.java#L197-L233","documentation":"QueryReplayer.fromString parses a target host string of the form user:password@host[:port]. If the user-info section before '@' does not split into exactly two colon-separated parts — i.e. a username was given without a password — this RuntimeException is thrown. Both credentials must be supplied for authenticated replay targets.","triggerScenarios":"Passing a --target like 'admin@127.0.0.1' where the user-info part before '@' lacks ':password'.","commonSituations":"Users typing shell-style credentials (user@host) instead of the required user:password@host syntax.","solutions":["Supply both username and password: --target user:password@host:port","If authentication is not needed, drop the user info entirely: --target host:port"],"exampleFix":"// before\n--target admin@127.0.0.1:9042\n// after\n--target admin:secret@127.0.0.1:9042","handlingStrategy":"validation","validationCode":"function validateTarget(t) {\n  const at = t.indexOf('@');\n  if (at > -1 && !t.slice(0, at).includes(':')) throw new Error('target needs user:password@host:port, got: ' + t);\n}","typeGuard":"const hasUserAndPassword = t => { const i = t.indexOf('@'); return i > -1 && t.slice(0, i).split(':').length === 2; };","tryCatchPattern":"try { parseTarget(arg); } catch (RuntimeException e) { if (e.getMessage().equals(\"Username provided but no password\")) { usage(\"--target must be user:password@host[:port]\"); } else throw e; }","preventionTips":["Always use the user:password@host:port form when credentials are needed","Keep passwords in env/config rather than embedding ad hoc","Validate CLI args with a script before invoking fqltool"],"tags":["cli","configuration","credentials"],"backgroundTag":"missing-credentials","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}