apache/cassandra · error · RuntimeException

Username provided but no password

Error message

Username provided but no password

What it means

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.

Source

Thrown at tools/fqltool/src/org/apache/cassandra/fqltool/QueryReplayer.java:215

        {
            this.host = host;
            this.port = port;
            this.user = user;
            this.password = password;
        }

        static ParsedTargetHost fromString(String s)
        {
            String [] userInfoHostPort = s.split("@");

            String hostPort = null;
            String user = null;
            String password = null;
            if (userInfoHostPort.length == 2)
            {
                String [] userPassword = userInfoHostPort[0].split(":");
                if (userPassword.length != 2)
                    throw new RuntimeException("Username provided but no password");
                hostPort = userInfoHostPort[1];
                user = userPassword[0];
                password = userPassword[1];
            }
            else if (userInfoHostPort.length == 1)
                hostPort = userInfoHostPort[0];
            else
                throw new RuntimeException("Malformed target host: "+s);

            String[] splitHostPort = hostPort.split(":");
            int port = 9042;
            if (splitHostPort.length == 2)
                port = Integer.parseInt(splitHostPort[1]);

            return new ParsedTargetHost(splitHostPort[0], port, user, password);
        }
    }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Supply both username and password: --target user:password@host:port
  2. If authentication is not needed, drop the user info entirely: --target host:port

Example fix

// before
--target admin@127.0.0.1:9042
// after
--target admin:secret@127.0.0.1:9042
Defensive patterns

Strategy: validation

Validate before calling

function validateTarget(t) {
  const at = t.indexOf('@');
  if (at > -1 && !t.slice(0, at).includes(':')) throw new Error('target needs user:password@host:port, got: ' + t);
}

Type guard

const hasUserAndPassword = t => { const i = t.indexOf('@'); return i > -1 && t.slice(0, i).split(':').length === 2; };

Try / catch

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; }

Prevention

When it happens

Trigger: Passing a --target like 'admin@127.0.0.1' where the user-info part before '@' lacks ':password'.

Common situations: Users typing shell-style credentials (user@host) instead of the required user:password@host syntax.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/f964bb1c5d890af3. Report an issue: GitHub.