{"record":{"id":"562c5e358a418cf1","repo":"apache/beam","slug":"failed-to-decode-url-parameters","errorCode":null,"errorMessage":"Failed to decode URL parameters: ","messagePattern":"Failed to decode URL parameters: ","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":113,"sourceCode":"    String actualUrl = extractHttpUrl(jdbcUrl);\n\n    try {\n      URI uri = new URI(actualUrl);\n\n      validateScheme(uri.getScheme());\n      String host = validateAndGetHost(uri.getHost(), jdbcUrl);\n      int port = getPortOrDefault(uri.getPort(), uri.getScheme());\n\n      String clickHouseUrl = String.format(\"%s://%s:%d\", uri.getScheme(), host, port);\n      String database = extractDatabase(uri.getPath());\n      Properties properties = extractProperties(uri.getQuery());\n\n      return new ParsedJdbcUrl(clickHouseUrl, database, properties);\n\n    } catch (URISyntaxException e) {\n      throw new IllegalArgumentException(\"Invalid JDBC URL format: \" + jdbcUrl, e);\n    } catch (java.io.UnsupportedEncodingException e) {\n      throw new IllegalArgumentException(\"Failed to decode URL parameters: \" + jdbcUrl, e);\n    }\n  }\n\n  /**\n   * Extracts and normalizes the HTTP/HTTPS URL from a JDBC URL.\n   *\n   * <p>Automatically detects HTTPS based on port 8443 or ssl=true parameter.\n   *\n   * @param jdbcUrl the JDBC URL to process\n   * @return normalized HTTP/HTTPS URL\n   * @throws IllegalArgumentException if the URL format is invalid\n   */\n  private static String extractHttpUrl(String jdbcUrl) {\n    // Remove jdbc: prefix\n    String urlWithoutJdbc = jdbcUrl;\n    if (jdbcUrl.toLowerCase().startsWith(\"jdbc:\")) {\n      urlWithoutJdbc = jdbcUrl.substring(5);\n    }","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/clickhouse/src/main/java/org/apache/beam/sdk/io/clickhouse/ClickHouseJdbcUrlParser.java#L95-L131","documentation":"Thrown by ClickHouseJdbcUrlParser.parse when a URL query parameter cannot be percent-decoded (java.io.UnsupportedEncodingException caught and rethrown). The parser preserves the original jdbcUrl in the message for debugging.","triggerScenarios":"Parsing a jdbc:clickhouse: or jdbc:ch: URL whose query string contains malformed percent-encoding — e.g. a bare % not followed by two hex digits (password=100%) — or whose parameter decoding fails on the charset.","commonSituations":"Double-encoding when the URL was already decoded once; passwords/tokens containing % pasted verbatim; older tooling emitting non-UTF-8 percent escapes.","solutions":["Fix malformed percent escapes in the query string (replace bare % with %25).","Percent-encode parameter values with URLEncoder.encode(value, StandardCharsets.UTF_8) before building the URL.","Pass special-character values via the Properties/DataSource API instead of embedding them in the URL.","Check whether the URL was double-encoded by an earlier processing step."],"exampleFix":"// before\nString url = \"jdbc:clickhouse://host:8123/default?password=pa%ss\"; // invalid percent escape\n// after\nString url = \"jdbc:clickhouse://host:8123/default?password=\" + URLEncoder.encode(\"pa%ss\", StandardCharsets.UTF_8);","handlingStrategy":"validation","validationCode":"boolean hasValidPercentEncoding(String query) {\n  if (query == null) return true;\n  java.util.regex.Matcher m = java.util.regex.Pattern.compile(\"%[^0-9A-Fa-f]{2}|%(?![0-9A-Fa-f]{2})\").matcher(query);\n  return !m.find();\n}","typeGuard":"boolean isSafelyEncodable(String paramValue) {\n  return paramValue != null && !paramValue.contains(\"%\") && paramValue.matches(\"[\\\\x20-\\\\x7E]*\");\n}","tryCatchPattern":"try {\n  ParsedJdbcUrl parsed = ClickHouseJdbcUrlParser.parse(jdbcUrl);\n} catch (IllegalArgumentException e) {\n  if (e.getCause() instanceof java.io.UnsupportedEncodingException) {\n    throw new ConfigException(\"URL query parameters contain invalid percent-encoding\", e);\n  }\n  throw e;\n}","preventionTips":["Always URLEncoder.encode(value, StandardCharsets.UTF_8) query parameter values.","Watch for double-encoding when URLs pass through multiple processing stages.","Pass passwords/tokens with special characters via Properties or the DataSource instead of the URL.","Unit-test URL construction with values containing %, +, &, =, and spaces."],"tags":["jdbc","clickhouse","url-parsing","encoding"],"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"}