t8y2/dbx · error
invalid Cassandra port: %s
Error message
invalid Cassandra port: %s
What it means
applyConnectionString validates the port parsed from the URL host and returns "invalid Cassandra port: %s" when strconv.Atoi fails or the number is outside 1–65535. The port must be a valid TCP port for the driver to configure the CQL connection.
Source
Thrown at agents/drivers/cassandra-go/config.go:134
}
parsed, err := url.Parse(value)
if err != nil {
return fmt.Errorf("invalid Cassandra connection string: %w", err)
}
if parsed.Scheme != "cassandra" {
return fmt.Errorf("unsupported Cassandra connection scheme: %s", parsed.Scheme)
}
if parsed.User != nil {
config.username = parsed.User.Username()
if password, ok := parsed.User.Password(); ok {
config.password = password
}
}
config.hosts = splitHosts(parsed.Host)
if port := parsed.Port(); port != "" {
parsedPort, parseErr := strconv.Atoi(port)
if parseErr != nil || parsedPort < 1 || parsedPort > 65535 {
return fmt.Errorf("invalid Cassandra port: %s", port)
}
config.port = parsedPort
}
if keyspace := strings.Trim(strings.TrimSpace(parsed.Path), "/"); keyspace != "" {
config.keyspace = keyspace
}
for key, values := range parsed.Query() {
params[key] = values
}
return nil
}
func parseURLParams(raw string) (url.Values, error) {
raw = strings.TrimPrefix(strings.TrimSpace(raw), "?")
if raw == "" {
return url.Values{}, nil
}
values, err := url.ParseQuery(raw)View on GitHub (pinned to c0390bff16)
Solutions
- Use a valid numeric port 1–65535, typically 9042 for CQL.
- Remove trailing characters or extra values after the port.
- Omit the port entirely to use the driver default.
- Pre-validate with strconv.Atoi and range-check before building the URL.
Example fix
// before
driver.Open("cassandra://10.0.0.5:9042,9142/sales")
// after
driver.Open("cassandra://10.0.0.5:9042/sales") Defensive patterns
Strategy: validation
Validate before calling
if u, err := url.Parse(strings.TrimPrefix(dsn, "jdbc:")); err == nil {
if p := u.Port(); p != "" {
n, e := strconv.Atoi(p)
if e != nil || n < 1 || n > 65535 {
return fmt.Errorf("port %q out of range 1-65535", p)
}
}
} Try / catch
conn, err := driver.Open(dsn)
if err != nil && strings.Contains(err.Error(), "invalid Cassandra port") {
return nil, fmt.Errorf("use a numeric TCP port 1-65535 (CQL default 9042): %w", err)
} Prevention
- Default to port 9042 for CQL and omit it from the DSN when standard.
- Never place comma-separated multi-port values in the port slot; list hosts separately.
- Range-check ports with strconv.Atoi when building DSNs from user input.
- Do not confuse CQL port 9042 with thrift (9160) or storage (7000) ports.
When it happens
Trigger: Connection strings like "cassandra://host:9042x", "cassandra://host:0", "cassandra://host:70000", or "cassandra://host:" where the Port() substring is non-empty but not a number in range.
Common situations: Typo appending a character to the port; using 0 as a placeholder; copy-pasting a multi-port value (9042,9142) into the port slot; confusing the CQL port (9042) with the thrift/storage ports (9160/7000).
Related errors
- Agent runtime thread limits must be positive
- Unsupported H2 driver profile: " + profile
- JDBC URL is required.
- BENCH_CANDIDATES selected no candidates
- unknown workload kind: {workload['kind']}
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/d93e9668ff28a495.
Report an issue: GitHub.