{"record":{"id":"1a53821b842e1df1","repo":"t8y2/dbx","slug":"invalid-tdengine-https-connection-string","errorCode":null,"errorMessage":"invalid TDengine HTTPS connection string","messagePattern":"invalid TDengine HTTPS connection string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/tdengine/src/config.rs","lineNumber":104,"sourceCode":"    } 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()))\n        .collect::<Vec<_>>();\n    let mut query = url.query_pairs_mut();\n    for (key, value) in additions {\n        query.append_pair(&key, &value);\n    }","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/tdengine/src/config.rs#L86-L122","documentation":"The https:// counterpart of the HTTP variant: normalize_connection_string rewrites https schemes to wss via Url::set_scheme, and if that mutator fails it raises 'invalid TDengine HTTPS connection string'. set_scheme can fail when the URL's port/default-port state is incompatible with the new scheme, so an https DSN could not be converted to a WebSocket-secure DSN.","triggerScenarios":"Passing an https:// connection string to build_dsn where Url::set_scheme(\"wss\") fails, e.g. a URL bound to http default port semantics or missing an explicit port.","commonSituations":"Users reusing TLS REST endpoint URLs (https://host:6041/rest/...) for the WebSocket agent, or URLs behind proxies that omit the port.","solutions":["Specify the scheme as wss:// directly in the connection string.","Add an explicit port to the URL to avoid scheme-rewrite port conflicts.","Confirm the endpoint actually serves the TDengine WebSocket protocol on that port."],"exampleFix":"// before\nlet dsn = build_dsn(Some(\"https://db.example.com\"), &params)?;\n// after\nlet dsn = build_dsn(Some(\"wss://db.example.com:6041\"), &params)?;","handlingStrategy":"validation","validationCode":"// Rust\nlet url = url::Url::parse(conn_str)?;\nif url.scheme() == \"https\" {\n    return Err(\"rewrite https:// to wss:// with an explicit port before passing to build_dsn\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use wss:// directly for TLS WebSocket endpoints.","Always specify the port explicitly to avoid scheme-rewrite conflicts.","Verify the endpoint speaks the WebSocket protocol, not the REST API."],"tags":["tdengine","websocket","tls"],"backgroundTag":"invalid-connection-string","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"}