{"record":{"id":"8f2ebc24e3810e3f","repo":"risingwavelabs/risingwave","slug":"missing-db-name-in-jdbc-url","errorCode":null,"errorMessage":"missing db_name in jdbc url","messagePattern":"missing db_name in jdbc url","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/stream/src/from_proto/sink.rs","lineNumber":409,"sourceCode":"        )\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 {\n        host: host.to_owned(),\n        port,\n        db_name: db_name.to_owned(),\n        username,\n        password,","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/stream/src/from_proto/sink.rs#L391-L427","documentation":"`parse_jdbc_url` derives the database name from the URL path and bails with 'missing db_name in jdbc url' when the path does not begin with `/` followed by a name (i.e. `url.path().strip_prefix('/')` fails on an empty path).","triggerScenarios":"A sink URL like `jdbc:postgresql://host:5432` or `jdbc:postgresql://host:5432/` with no database segment after the port.","commonSituations":"Users omitting the database name because some client tools default to the username; truncated URLs; editing the URL and dropping the trailing `/dbname`.","solutions":["Append the database name: `jdbc:postgresql://host:5432/dbname`.","Ensure there is exactly one `/` then the db name after the port (query params come after `?`).","Do not leave a trailing slash with empty db name.","Recreate the sink after fixing the URL."],"exampleFix":"// before\njdbc.url = 'jdbc:postgresql://host:5432/'\n// after\njdbc.url = 'jdbc:postgresql://host:5432/mydb'","handlingStrategy":"validation","validationCode":"let stripped = jdbc_url.strip_prefix(\"jdbc:\").unwrap();\nlet has_db = url::Url::parse(stripped).ok().map(|u| u.path().len() > 1).unwrap_or(false);\nassert!(has_db, \"jdbc url must include /dbname\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never end the URL at the port; always include /dbname.","Don't rely on client-side default databases — name it explicitly.","Validate all four parts (host, port, db, scheme) before CREATE SINK."],"tags":["jdbc","url-parsing","missing-database","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"}