{"record":{"id":"918532842d10a31e","repo":"t8y2/dbx","slug":"parse-iotdb-connection-string-w","errorCode":null,"errorMessage":"parse IoTDB connection string: %w","messagePattern":"parse IoTDB connection string: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/iotdb/driver.go","lineNumber":117,"sourceCode":"\tif config.Host == \"\" {\n\t\tconfig.Host = \"127.0.0.1\"\n\t}\n\tif config.Port <= 0 {\n\t\tconfig.Port = defaultIoTDBPort\n\t}\n\tif config.Username == \"\" {\n\t\tconfig.Username = \"root\"\n\t}\n\tif config.Password == \"\" {\n\t\tconfig.Password = \"root\"\n\t}\n\n\tquery := url.Values{}\n\tif raw := strings.TrimSpace(params.ConnectionString); raw != \"\" {\n\t\tnormalized := strings.TrimPrefix(raw, \"jdbc:\")\n\t\tparsed, err := url.Parse(normalized)\n\t\tif err != nil {\n\t\t\treturn connectionConfig{}, fmt.Errorf(\"parse IoTDB connection string: %w\", err)\n\t\t}\n\t\tif parsed.Scheme != \"\" && !strings.EqualFold(parsed.Scheme, \"iotdb\") {\n\t\t\treturn connectionConfig{}, fmt.Errorf(\"unsupported IoTDB connection scheme: %s\", parsed.Scheme)\n\t\t}\n\t\tif parsed.Hostname() != \"\" {\n\t\t\tconfig.Host = parsed.Hostname()\n\t\t}\n\t\tif parsed.Port() != \"\" {\n\t\t\tport, err := strconv.Atoi(parsed.Port())\n\t\t\tif err != nil || port <= 0 {\n\t\t\t\treturn connectionConfig{}, fmt.Errorf(\"invalid IoTDB port: %s\", parsed.Port())\n\t\t\t}\n\t\t\tconfig.Port = port\n\t\t}\n\t\tif parsed.User != nil {\n\t\t\tif username := parsed.User.Username(); username != \"\" {\n\t\t\t\tconfig.Username = username\n\t\t\t}","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/iotdb/driver.go#L99-L135","documentation":"parseConnectionConfig parses the IoTDB connection string: it strips an optional 'jdbc:' prefix and runs url.Parse. If URL parsing fails, the error is wrapped as 'parse IoTDB connection string: %w'. This surfaces malformed connection strings early.","triggerScenarios":"Passing a ConnectionString with invalid URL syntax — e.g. unescaped characters, mismatched brackets in IPv6 host, or a ':' only host:port fragment like 'host:' — to newServer.","commonSituations":"Building the string by concatenation with an unencoded password containing '@' or ':'; forgetting jdbc: prefix handling and embedding spaces; IPv6 addresses without brackets.","solutions":["URL-encode the username/password (url.QueryEscape) before composing the string","Validate the connection string with url.Parse in your own code before passing it","Remove spaces/invalid characters; bracket IPv6 hosts","Log the normalized (jdbc-stripped) string that failed to confirm the syntax problem"],"exampleFix":"// before\nconnStr := fmt.Sprintf(\"iotdb://%s:%s@host:6667\", user, password) // password has '@'\n// after\nconnStr := fmt.Sprintf(\"iotdb://%s:%s@host:6667\", url.QueryEscape(user), url.QueryEscape(password))","handlingStrategy":"validation","validationCode":"func validateIoTDBConnStr(raw string) error {\n  normalized := strings.TrimPrefix(strings.TrimSpace(raw), \"jdbc:\")\n  if _, err := url.Parse(normalized); err != nil {\n    return fmt.Errorf(\"invalid connection string: %w\", err)\n  }\n  return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["URL-encode credentials with url.QueryEscape when composing strings","Avoid spaces and raw special characters in connection strings","Bracket IPv6 hosts and encode any '%' characters"],"tags":["iotdb","config","url-parsing","connection-string"],"backgroundTag":"malformed-connection-string","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}