{"record":{"id":"fb6230207cd343c1","repo":"risingwavelabs/risingwave","slug":"failed-to-parse-jdbc-url","errorCode":null,"errorMessage":"failed to parse jdbc url","messagePattern":"failed to parse jdbc url","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/stream/src/from_proto/sink.rs","lineNumber":398,"sourceCode":"    host: String,\n    port: u16,\n    db_name: String,\n    username: Option<String>,\n    password: Option<String>,\n}\n\nfn parse_jdbc_url(url: &str) -> anyhow::Result<JdbcUrl> {\n    if !url.starts_with(\"jdbc:postgresql\") {\n        bail!(\n            \"invalid jdbc url, to switch to postgres rust connector, we need to use the url jdbc:postgresql://...\"\n        )\n    }\n\n    // trim the \"jdbc:\" prefix to make it a valid url\n    let url = url.replace(\"jdbc:\", \"\");\n\n    // parse the url\n    let url = Url::parse(&url).map_err(|e| anyhow!(e).context(\"failed to parse jdbc url\"))?;\n\n    let scheme = url.scheme();\n    assert_eq!(\"postgresql\", scheme, \"jdbc scheme should be postgresql\");\n    let host = url\n        .host_str()\n        .ok_or_else(|| anyhow!(\"missing host in jdbc url\"))?;\n    let port = url\n        .port()\n        .ok_or_else(|| anyhow!(\"missing port in jdbc url\"))?;\n    let Some(db_name) = url.path().strip_prefix('/') else {\n        bail!(\"missing db_name in jdbc url\");\n    };\n    let mut username = None;\n    let mut password = None;\n    for (key, value) in url.query_pairs() {\n        if key == \"user\" {\n            username = Some(value.to_string());\n        }","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/stream/src/from_proto/sink.rs#L380-L416","documentation":"After stripping the `jdbc:` prefix, `parse_jdbc_url` parses the remainder with the `url` crate. If the remaining string is not a valid absolute URL (bad scheme/host syntax, unparseable authority, invalid characters), the parse error is wrapped with this context: 'failed to parse jdbc url'.","triggerScenarios":"A URL like `jdbc:postgresql:host:5432/db` or `jdbc:postgresql:///db` without a host, or containing spaces/illegal characters, that fails `Url::parse` after the `jdbc:` prefix is removed.","commonSituations":"Typos such as missing `//` after the scheme; unencoded special characters (spaces, `#`) in password or database name; hand-edited URLs in sink properties.","solutions":["Use the canonical form `jdbc:postgresql://host:port/dbname?user=...&password=...`.","URL-encode special characters (e.g. `@`, `#`, spaces) in user/password via percent-encoding.","Verify no stray whitespace or quotes were pasted into the `jdbc.url` property.","Test the URL by stripping `jdbc:` and confirming it parses as a standard postgres URL."],"exampleFix":"// before\njdbc.url = 'jdbc:postgresql://my host:5432/db'\n// after\njdbc.url = 'jdbc:postgresql://my-host:5432/db'","handlingStrategy":"validation","validationCode":"let stripped = jdbc_url.strip_prefix(\"jdbc:\").unwrap();\nassert!(url::Url::parse(stripped).is_ok(), \"jdbc url must parse after stripping jdbc: prefix\");","typeGuard":null,"tryCatchPattern":"match sink_creation_result { Err(e) if e.to_string().contains(\"failed to parse jdbc url\") => { /* fix and resubmit CREATE SINK */ }, ... }","preventionTips":["Percent-encode special characters in user/password.","Avoid spaces and stray quotes in the URL property.","Test the URL with any standard URL parser before applying."],"tags":["jdbc","url-parsing","sink"],"backgroundTag":"invalid-url-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}