{"record":{"id":"7dcc429f21cce83a","repo":"t8y2/dbx","slug":"invalid-cassandra-connection-string-w","errorCode":null,"errorMessage":"invalid Cassandra connection string: %w","messagePattern":"invalid Cassandra connection string: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/cassandra-go/config.go","lineNumber":119,"sourceCode":"\t}\n\tif len(config.hosts) == 0 && config.secureConnectBundle == \"\" {\n\t\treturn cassandraConfig{}, fmt.Errorf(\"Cassandra host is required\")\n\t}\n\tif len(config.hosts) > 0 && !config.disableInitialHostLookup && allLoopbackHosts(config.hosts) {\n\t\tconfig.disableInitialHostLookup = true\n\t}\n\treturn config, nil\n}\n\nfunc applyConnectionString(config *cassandraConfig, params url.Values, raw string) error {\n\tvalue := strings.TrimSpace(raw)\n\tvalue = strings.TrimPrefix(value, \"jdbc:\")\n\tif !strings.Contains(value, \"://\") {\n\t\treturn fmt.Errorf(\"unsupported Cassandra connection string: %s\", raw)\n\t}\n\tparsed, err := url.Parse(value)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid Cassandra connection string: %w\", err)\n\t}\n\tif parsed.Scheme != \"cassandra\" {\n\t\treturn fmt.Errorf(\"unsupported Cassandra connection scheme: %s\", parsed.Scheme)\n\t}\n\tif parsed.User != nil {\n\t\tconfig.username = parsed.User.Username()\n\t\tif password, ok := parsed.User.Password(); ok {\n\t\t\tconfig.password = password\n\t\t}\n\t}\n\tconfig.hosts = splitHosts(parsed.Host)\n\tif port := parsed.Port(); port != \"\" {\n\t\tparsedPort, parseErr := strconv.Atoi(port)\n\t\tif parseErr != nil || parsedPort < 1 || parsedPort > 65535 {\n\t\t\treturn fmt.Errorf(\"invalid Cassandra port: %s\", port)\n\t\t}\n\t\tconfig.port = parsedPort\n\t}","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/cassandra-go/config.go#L101-L137","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ndriver.Open(\"cassandra://admin:p@ss%zz@10.0.0.5:9042/sales\") // bad escape\n// after\nu := url.UserPassword(\"admin\", \"p@ss\")\ndriver.Open(\"cassandra://\" + u.String() + \"@10.0.0.5:9042/sales\")","handlingStrategy":"validation","validationCode":"v := strings.TrimPrefix(strings.TrimSpace(dsn), \"jdbc:\")\nif _, err := url.Parse(v); err != nil {\n    return fmt.Errorf(\"DSN is not a parseable URL: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"conn, err := driver.Open(dsn)\nif err != nil && strings.Contains(err.Error(), \"invalid Cassandra connection string\") {\n    return nil, fmt.Errorf(\"malformed URL in DSN %q: %w\", dsn, err)\n}","preventionTips":["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."],"tags":["configuration","cassandra","url-parsing"],"backgroundTag":"invalid-url-syntax","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}