{"record":{"id":"362450ab107be9de","repo":"apache/beam","slug":"invalid-scheme-expected-http-or-https-got","errorCode":null,"errorMessage":"Invalid scheme. Expected 'http' or 'https'. Got: ","messagePattern":"Invalid scheme\\. 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":193,"sourceCode":"    // 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\n   * @throws IllegalArgumentException if scheme is invalid\n   */\n  private static void validateScheme(String scheme) {\n    if (scheme == null || (!scheme.equals(\"http\") && !scheme.equals(\"https\"))) {\n      throw new IllegalArgumentException(\n          \"Invalid scheme. Expected 'http' or 'https'. Got: \" + scheme);\n    }\n  }\n\n  /**\n   * Validates and returns the host from the URI.\n   *\n   * @param host the host to validate\n   * @param jdbcUrl the original JDBC URL (for error reporting)\n   * @return the validated host\n   * @throws IllegalArgumentException if host is invalid\n   */\n  private static String validateAndGetHost(String host, String jdbcUrl) {\n    if (Strings.isNullOrEmpty(host)) {\n      throw new IllegalArgumentException(\"Host cannot be empty in JDBC URL: \" + jdbcUrl);\n    }\n    return host;\n  }","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/clickhouse/src/main/java/org/apache/beam/sdk/io/clickhouse/ClickHouseJdbcUrlParser.java#L175-L211","documentation":"Thrown by ClickHouseJdbcUrlParser.validateScheme when the URI scheme extracted from the JDBC URL is neither 'http' nor 'https' (or is null). A final check ensuring the connection target uses a transport this connector implements.","triggerScenarios":"Parsing a URL whose protocol is not http/https (e.g. 'jdbc:clickhouse:ftp://host/path') or a malformed/relative URI whose getScheme() returns null.","commonSituations":"URLs copied from other tooling with custom schemes; truncated URLs losing the scheme; config templates where the protocol variable interpolated empty.","solutions":["Use 'http://' or 'https://' as the protocol in the JDBC URL.","Check that the configured URL template actually interpolates the scheme variable (no empty ${SCHEME}).","Compare against the message's scheme value to see what was actually parsed.","Confirm the ClickHouse server's HTTP/HTTPS port is used."],"exampleFix":"// before\nString url = \"jdbc:clickhouse:ftp://host/path\";\n// after\nString url = \"jdbc:clickhouse:https://host:8443/path\";","handlingStrategy":"validation","validationCode":"boolean schemeIsHttpOrHttps(String url) {\n  if (url == null) return false;\n  try {\n    String scheme = new java.net.URI(url).getScheme();\n    return \"http\".equals(scheme) || \"https\".equals(scheme);\n  } catch (java.net.URISyntaxException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  ParsedJdbcUrl parsed = ClickHouseJdbcUrlParser.parse(jdbcUrl);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid scheme.\")) {\n    throw new ConfigException(\"ClickHouse JDBC URL must use http or https scheme: \" + jdbcUrl, e);\n  }\n  throw e;\n}","preventionTips":["Ensure config templates always interpolate a non-empty scheme variable.","Default to https:// in production configurations.","Validate the fully-rendered URL at configuration load time, not at write time.","Log the rendered URL (minus credentials) once at startup to catch scheme drift early."],"tags":["jdbc","clickhouse","url-parsing"],"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"}