{"record":{"id":"000432a5daf54749","repo":"t8y2/dbx","slug":"tdengine-native-agent-supports-only-websocket-conn","errorCode":null,"errorMessage":"TDengine native agent supports only WebSocket connection strings","messagePattern":"TDengine native agent supports only WebSocket connection strings","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/tdengine/src/config.rs","lineNumber":99,"sourceCode":"\nfn normalize_connection_string(raw: &str, ssl: bool) -> Result<Url> {\n    let trimmed = raw.trim();\n    let normalized = if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, \"jdbc:TAOS-WS://\") {\n        format!(\"{}://{value}\", if ssl { \"wss\" } else { \"ws\" })\n    } else if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, \"jdbc:TAOS-RS://\") {\n        format!(\"{}://{value}\", if ssl { \"wss\" } else { \"ws\" })\n    } else if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, \"tdengine://\") {\n        format!(\"{}://{value}\", if ssl { \"wss\" } else { \"ws\" })\n    } else if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, \"taosws://\") {\n        format!(\"{}://{value}\", if ssl { \"wss\" } else { \"ws\" })\n    } else if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, \"taoswss://\") {\n        format!(\"wss://{value}\")\n    } else {\n        trimmed.to_string()\n    };\n    let mut url = Url::parse(&normalized).with_context(|| \"invalid TDengine connection string\")?;\n    if !matches!(url.scheme(), \"ws\" | \"wss\" | \"http\" | \"https\") {\n        bail!(\"TDengine native agent supports only WebSocket connection strings\");\n    }\n    if matches!(url.scheme(), \"http\") {\n        url.set_scheme(\"ws\").map_err(|_| anyhow::anyhow!(\"invalid TDengine HTTP connection string\"))?;\n    } else if matches!(url.scheme(), \"https\") {\n        url.set_scheme(\"wss\").map_err(|_| anyhow::anyhow!(\"invalid TDengine HTTPS connection string\"))?;\n    }\n    remove_control_params(&mut url);\n    Ok(url)\n}\n\nfn merge_query_params(url: &mut Url, raw: &str) {\n    let raw = raw.trim().trim_start_matches('?');\n    if raw.is_empty() {\n        return;\n    }\n    let additions = url::form_urlencoded::parse(raw.as_bytes())\n        .filter(|(key, _)| !is_control_param(key))\n        .map(|(key, value)| (key.into_owned(), value.into_owned()))","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/tdengine/src/config.rs#L81-L117","documentation":"normalize_connection_string parses the provided TDengine connection string and enforces that the agent only speaks WebSocket (ws/wss, with http/https auto-upgraded). Any other scheme — e.g. taos, jdbc:taos, or postgres — is rejected. This prevents accidentally pointing the WebSocket agent at a native/JDBC endpoint it cannot handle.","triggerScenarios":"Passing a connection string with a scheme other than ws/wss/http/https, such as 'taos://host:6030' or a legacy 'jdbc:TAOS-RS://...' URL, into ConnectParams.connection_string.","commonSituations":"Reusing a JDBC URL from an existing Java app, copying a native taos:// DSN from TDengine docs, or forgetting the ws:// prefix entirely.","solutions":["Change the scheme to ws:// or wss:// (e.g. ws://host:6041)","http:// and https:// are accepted and auto-converted to ws/wss — prefer those if pointing at the REST/WebSocket port","Strip jdbc:TAOS-RS:// prefixes and convert the remainder into a ws:// URL"],"exampleFix":"// before\nconnection_string = \"jdbc:TAOS-RS://tdengine:6041\"\n// after\nconnection_string = \"ws://tdengine:6041\"","handlingStrategy":"validation","validationCode":"let url = url::Url::parse(&params.connection_string)?;\nif !matches!(url.scheme(), \"ws\" | \"wss\" | \"http\" | \"https\") {\n    return Err(anyhow!(\"use ws:// or wss:// scheme\"));\n}","typeGuard":"fn is_ws_scheme(s: &str) -> bool {\n    url::Url::parse(s).map(|u| matches!(u.scheme(), \"ws\" | \"wss\" | \"http\" | \"https\")).unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Normalize JDBC URLs before storing connection profiles","Default to ws://host:6041 for the WebSocket port","Reject taos:// schemes in UI input validation"],"tags":["rust","tdengine","connection-string","websocket","configuration"],"backgroundTag":"unsupported-connection-scheme","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"}