{"record":{"id":"79b22635b3a1bf40","repo":"apache/cassandra","slug":"malformed-target-host-s","errorCode":null,"errorMessage":"Malformed target host: ${s}","messagePattern":"Malformed target host: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"tools/fqltool/src/org/apache/cassandra/fqltool/QueryReplayer.java","lineNumber":223,"sourceCode":"        {\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\n    public static interface SessionProvider extends Closeable\n    {\n        Session connect(String connectionString);\n        void close();\n    }\n\n    private static final class DefaultSessionProvider implements SessionProvider\n    {","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/fqltool/src/org/apache/cassandra/fqltool/QueryReplayer.java#L205-L241","documentation":"QueryReplayer.fromString splits the target string on '@' and expects either one part (host[:port]) or two (user:password@host[:port]). Any other shape — e.g. multiple '@' characters producing more segments — cannot be parsed, so it throws with the offending string. It is a strict syntax check on the --target argument.","triggerScenarios":"Passing a --target value containing more than one '@' (e.g. 'us@er:pw@host').","commonSituations":"Usernames containing '@' (common with email addresses used as credentials); copy-paste errors adding extra '@' characters.","solutions":["Remove or escape '@' characters inside the username/password, or use credentials without '@'","Ensure the target has at most one '@' separating credentials from host[:port]"],"exampleFix":"// before\n--target admin@example.com:pw@127.0.0.1\n// after\n--target admin:pw@127.0.0.1","handlingStrategy":"validation","validationCode":"function validateTarget(t) {\n  if (t.split('@').length > 2) throw new Error('at most one @ allowed in target: ' + t);\n}","typeGuard":"const wellFormedTarget = t => t.split('@').length <= 2;","tryCatchPattern":"try { parseTarget(arg); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Malformed target host\")) { usage(\"target format: [user:password@]host[:port]\"); } else throw e; }","preventionTips":["Avoid '@' in usernames/passwords, or rotate such credentials","Quote the --target argument in shell scripts","Sanitize copy-pasted connection strings before use"],"tags":["cli","configuration","parsing"],"backgroundTag":"invalid-argument-format","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"}