t8y2/dbx · error
invalid Cassandra connection string: %w
Error message
invalid Cassandra connection string: %w
What it means
applyConnectionString wraps a url.Parse failure with "invalid Cassandra connection string: %w". After confirming the string contains '://', it is parsed with net/url; malformed URLs (bad percent-escapes, invalid characters) fail and are re-raised with this message, preserving the underlying cause.
Source
Thrown at agents/drivers/cassandra-go/config.go:119
}
if len(config.hosts) == 0 && config.secureConnectBundle == "" {
return cassandraConfig{}, fmt.Errorf("Cassandra host is required")
}
if len(config.hosts) > 0 && !config.disableInitialHostLookup && allLoopbackHosts(config.hosts) {
config.disableInitialHostLookup = true
}
return config, nil
}
func applyConnectionString(config *cassandraConfig, params url.Values, raw string) error {
value := strings.TrimSpace(raw)
value = strings.TrimPrefix(value, "jdbc:")
if !strings.Contains(value, "://") {
return fmt.Errorf("unsupported Cassandra connection string: %s", raw)
}
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
}View on GitHub (pinned to c0390bff16)
Solutions
- Inspect the wrapped error to identify the exact parse failure (it names the offending offset/escape).
- Fix percent-encoding: escape special characters in user/password via url.QueryEscape/url.UserPassword.
- Remove stray whitespace, control characters, or unrendered template placeholders.
- Validate the URL locally with url.Parse before passing it to the driver.
Example fix
// before
driver.Open("cassandra://admin:p@ss%zz@10.0.0.5:9042/sales") // bad escape
// after
u := url.UserPassword("admin", "p@ss")
driver.Open("cassandra://" + u.String() + "@10.0.0.5:9042/sales") Defensive patterns
Strategy: validation
Validate before calling
v := strings.TrimPrefix(strings.TrimSpace(dsn), "jdbc:")
if _, err := url.Parse(v); err != nil {
return fmt.Errorf("DSN is not a parseable URL: %v", err)
} Try / catch
conn, err := driver.Open(dsn)
if err != nil && strings.Contains(err.Error(), "invalid Cassandra connection string") {
return nil, fmt.Errorf("malformed URL in DSN %q: %w", dsn, err)
} Prevention
- Escape user credentials with url.UserPassword before embedding them in the DSN.
- Beware double-encoding when the DSN passes through templating or env substitution.
- Sanitize copy-pasted values (strip whitespace, smart quotes, control characters).
- Pre-validate with url.Parse in application startup.
When it happens
Trigger: Passing a connection string whose URL portion cannot be parsed by url.Parse — e.g. "cassandra://%zz@host/keyspace" (invalid percent-encoding) or stray control characters/brackets in the host part.
Common situations: Copy-paste introduced invisible characters or smart quotes; unescaped special characters in an embedded password; templating left a literal like ${HOST} with illegal characters; truncated URL from a split config value.
Related errors
- unsupported Cassandra connection string: %s
- invalid Cassandra URL parameters: %w
- Hive connection string must start with jdbc:hive2:// or hive
- Cassandra host is required
- unsupported Cassandra connection scheme: %s
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/7dcc429f21cce83a.
Report an issue: GitHub.