{"record":{"id":"6d8a6cbc4e89f92c","repo":"apache/seatunnel","slug":"invalid-duckdb-jdbc-url","errorCode":null,"errorMessage":"Invalid DuckDB JDBC url: ","messagePattern":"Invalid DuckDB JDBC url: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/duckdb/DuckDBURLParser.java","lineNumber":41,"sourceCode":"import java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n/**\n * Parser for DuckDB JDBC URLs.\n *\n * <p>DuckDB is an embedded database, so URLs look like {@code jdbc:duckdb:}, {@code\n * jdbc:duckdb:/path/to/file.duckdb} or {@code jdbc:duckdb:memory:?option=value}. This parser\n * extracts the embedded database path (if any) and builds {@link JdbcUrlUtil.UrlInfo} accordingly.\n */\npublic class DuckDBURLParser {\n\n    private static final Pattern DUCKDB_URL_PATTERN =\n            Pattern.compile(\"^jdbc:duckdb:(?<path>[^?]*?)(?<suffix>\\\\?.*)?$\");\n\n    public static JdbcUrlUtil.UrlInfo parse(String url) {\n        Matcher matcher = DUCKDB_URL_PATTERN.matcher(url);\n        if (!matcher.matches()) {\n            throw new IllegalArgumentException(\"Invalid DuckDB JDBC url: \" + url);\n        }\n        String path = Optional.ofNullable(matcher.group(\"path\")).orElse(\"\");\n        String suffix = Optional.ofNullable(matcher.group(\"suffix\")).orElse(\"\");\n        return new JdbcUrlUtil.UrlInfo(url, \"jdbc:duckdb:\", \"localhost\", 0, path, suffix);\n    }\n}\n","sourceCodeStart":23,"sourceCodeEnd":48,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/duckdb/DuckDBURLParser.java#L23-L48","documentation":"DuckDBURLParser.parse validates a JDBC URL against the regex ^jdbc:duckdb:<path>(?<suffix>?query)?$ and throws IllegalArgumentException when the URL does not match. This means the URL is not a syntactically valid DuckDB JDBC URL, so the catalog cannot extract the database path.","triggerScenarios":"Calling parse with a URL that is null, empty, lacks the jdbc:duckdb: prefix (e.g. jdbc:mysql:..., duckdb://..., or a plain file path), or otherwise does not match the pattern.","commonSituations":"Copy-pasting a URL from another database's config; forgetting the jdbc:duckdb: prefix; using a URL that points at a server (jdbc:duckdb://host:port) which the pattern does not accept; extra whitespace.","solutions":["Rewrite the URL to the form jdbc:duckdb:<path>[?params], e.g. jdbc:duckdb:/data/mydb.duckdb","Remove any protocol/host/port portion — DuckDB is embedded, no host:port in the URL","URL-encode or move invalid characters; the path segment cannot contain characters that break the regex","Trim whitespace and check for typos in the scheme (all lowercase jdbc:duckdb:)"],"exampleFix":"// before\nString url = \"duckdb:///data/mydb.duckdb\"; // throws\n// after\nString url = \"jdbc:duckdb:/data/mydb.duckdb\";","handlingStrategy":"validation","validationCode":"public static boolean isValidDuckDbUrl(String url) {\n    return url != null && url.matches(\"^jdbc:duckdb:[^?]*(\\\\?.*)?$\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    JdbcUrlUtil.UrlInfo info = DuckDBURLParser.parse(url);\n} catch (IllegalArgumentException e) {\n    LOG.error(\"Bad DuckDB URL '{}': must be jdbc:duckdb:<path>\", url);\n}","preventionTips":["Always use the full jdbc:duckdb: scheme in lowercase","Do not include host:port — DuckDB is an embedded database","Trim whitespace from config-sourced URLs","Unit-test URL parsing for every URL template in your config"],"tags":["jdbc","duckdb","url","validation"],"backgroundTag":"invalid-url-format","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}