{"record":{"id":"2dc720718494a9c3","repo":"risingwavelabs/risingwave","slug":"missing-host-in-jdbc-url","errorCode":null,"errorMessage":"missing host in jdbc url","messagePattern":"missing host in jdbc url","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/stream/src/from_proto/sink.rs","lineNumber":404,"sourceCode":"\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        }\n        if key == \"password\" {\n            password = Some(value.to_string());\n        }\n    }\n\n    Ok(JdbcUrl {","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/stream/src/from_proto/sink.rs#L386-L422","documentation":"`parse_jdbc_url` extracts the host via `Url::host_str()` and bails with 'missing host in jdbc url' when the parsed URL has no host component (e.g. an empty or non-authority form). The postgres connector needs an explicit host to connect.","triggerScenarios":"A sink URL like `jdbc:postgresql:/dbname` or `jdbc:postgresql://:5432/db` (empty host) or a unix-socket-style URL, which yields `None` from `host_str()`.","commonSituations":"Users adapting JDBC URLs meant for local sockets (`jdbc:postgresql:///db`), or dropping the host while editing config files.","solutions":["Include an explicit host: `jdbc:postgresql://localhost:5432/mydb`.","If targeting a local instance, use `localhost` or `127.0.0.1` instead of a socket path.","Check for a deleted/empty host segment between `//` and `:` in the URL.","Recreate the sink after fixing the URL."],"exampleFix":"// before\njdbc.url = 'jdbc:postgresql:///mydb'\n// after\njdbc.url = 'jdbc:postgresql://localhost:5432/mydb'","handlingStrategy":"validation","validationCode":"let stripped = jdbc_url.strip_prefix(\"jdbc:\").unwrap();\nassert!(url::Url::parse(stripped).ok().and_then(|u| u.host_str().map(String::from)).is_some());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include an explicit host, even for local databases (localhost).","Never use unix-socket or host-less JDBC URL forms.","Keep host:port together when editing connection strings."],"tags":["jdbc","url-parsing","missing-host","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"}