{"record":{"id":"4f6f3ec75c3c8e11","repo":"apache/beam","slug":"invalid-scheme-in-jdbc-url-expected-http-or-https-got","errorCode":null,"errorMessage":"Invalid scheme in JDBC URL. Expected 'http' or 'https'. Got: ","messagePattern":"Invalid scheme in JDBC URL\\. Expected 'http' or 'https'\\. Got: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/clickhouse/src/main/java/org/apache/beam/sdk/io/clickhouse/ClickHouseJdbcUrlParser.java","lineNumber":170,"sourceCode":"    // Check if ssl=true in query string\n    if (actualUrl.toLowerCase().contains(\"ssl=true\")) {\n      useHttps = true;\n    }\n\n    // Check for invalid schemes before prepending http://\n    if (actualUrl.contains(\"://\")) {\n      // Extract the scheme part\n      int schemeEnd = actualUrl.indexOf(\"://\");\n      String scheme = actualUrl.substring(0, schemeEnd).toLowerCase();\n\n      if (scheme.equals(\"http\") || scheme.equals(\"https\")) {\n        // If http:// but ssl=true detected, upgrade to https://\n        if (scheme.equals(\"http\") && useHttps) {\n          actualUrl = \"https://\" + actualUrl.substring(schemeEnd + 3);\n        }\n        return actualUrl;\n      } else {\n        throw new IllegalArgumentException(\n            \"Invalid scheme in JDBC URL. Expected 'http' or 'https'. Got: \" + scheme);\n      }\n    }\n\n    // If URL doesn't start with http:// or https://, add the appropriate scheme\n    if (actualUrl.startsWith(\"//\")) {\n      actualUrl = (useHttps ? \"https:\" : \"http:\") + actualUrl;\n    } else {\n      actualUrl = (useHttps ? \"https://\" : \"http://\") + actualUrl;\n    }\n\n    return actualUrl;\n  }\n\n  /**\n   * Validates the URI scheme.\n   *\n   * @param scheme the scheme to validate","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/clickhouse/src/main/java/org/apache/beam/sdk/io/clickhouse/ClickHouseJdbcUrlParser.java#L152-L188","documentation":"Thrown by ClickHouseJdbcUrlParser.extractHttpUrl when the transport part of the JDBC URL begins with a scheme other than http:// or https:// (and the scheme-adding branch does not apply). Beam's ClickHouse IO supports HTTP/HTTPS transport only.","triggerScenarios":"Parsing a URL whose inner part after the clickhouse:/ch: prefix uses a non-HTTP scheme, e.g. 'jdbc:clickhouse:tcp://host:9000' (native protocol) or 'jdbc:ch:grpc://...'.","commonSituations":"Reusing URLs from the native ClickHouse JDBC driver, which defaults to tcp on port 9000; copying clickhouse-client connection strings; pointing the pipeline at a non-HTTP endpoint.","solutions":["Replace the scheme with http:// or https:// and use the HTTP port (8123 default, 8443 for HTTPS).","Remove the native 'tcp://' prefix; this connector speaks HTTP only.","For TLS, either use https:// explicitly or set ssl=true so http:// is upgraded.","Verify the server exposes the HTTP interface (http_port/https_port in config.xml)."],"exampleFix":"// before\nString url = \"jdbc:clickhouse:tcp://localhost:9000/default\"; // native protocol\n// after\nString url = \"jdbc:clickhouse:http://localhost:8123/default\";","handlingStrategy":"validation","validationCode":"boolean hasHttpScheme(String jdbcUrl) {\n  if (jdbcUrl == null) return false;\n  String s = jdbcUrl.toLowerCase();\n  int idx = s.indexOf(\"://\");\n  if (idx < 0) return false;\n  int start = Math.max(0, s.lastIndexOf(\":\", idx - 1) + 1);\n  String scheme = s.substring(start, idx);\n  return scheme.equals(\"http\") || scheme.equals(\"https\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  ParsedJdbcUrl parsed = ClickHouseJdbcUrlParser.parse(jdbcUrl);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Invalid scheme in JDBC URL\")) {\n    throw new ConfigException(\"Beam ClickHouse IO only supports HTTP/HTTPS transport (ports 8123/8443), not native tcp://\", e);\n  }\n  throw e;\n}","preventionTips":["Never reuse native ClickHouse JDBC (tcp://, port 9000) URLs with this connector.","Use http:// with port 8123 or https:// with port 8443.","Set ssl=true with http:// if TLS upgrade is desired instead of a custom scheme.","Verify the server's http_port/https_port in config.xml matches the URL."],"tags":["jdbc","clickhouse","url-parsing","network"],"backgroundTag":"invalid-url-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}