{"record":{"id":"526af8c4bb6395f6","repo":"apache/beam","slug":"property-conflict-s-is-already-set-to-s-likely-from-jdbc-url","errorCode":null,"errorMessage":"Property conflict: '%s' is already set to '%s' (likely from JDBC URL), but attempting to set it to '%s'. Please use either JDBC URL properties OR withProperties(), not both for the same keys.","messagePattern":"Property conflict: '(.+?)' is already set to '(.+?)' \\(likely from JDBC URL\\), but attempting to set it to '(.+?)'\\. Please use either JDBC URL properties OR withProperties\\(\\), not both for the same keys\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/clickhouse/src/main/java/org/apache/beam/sdk/io/clickhouse/ClickHouseIO.java","lineNumber":428,"sourceCode":"     *\n     * @param properties connection properties\n     * @return a {@link PTransform} writing data to ClickHouse\n     * @throws IllegalArgumentException if properties is null or if any property conflicts with\n     *     existing properties (e.g., from JDBC URL)\n     */\n    public Write<T> withProperties(Properties properties) {\n      if (properties == null) {\n        throw new IllegalArgumentException(\"Properties cannot be null\");\n      }\n\n      // Check for conflicts with existing properties\n      Properties existing = properties();\n      for (String key : properties.stringPropertyNames()) {\n        if (existing.containsKey(key)) {\n          String existingValue = existing.getProperty(key);\n          String newValue = properties.getProperty(key);\n          if (!existingValue.equals(newValue)) {\n            throw new IllegalArgumentException(\n                String.format(\n                    \"Property conflict: '%s' is already set to '%s' (likely from JDBC URL), \"\n                        + \"but attempting to set it to '%s'. \"\n                        + \"Please use either JDBC URL properties OR withProperties(), not both for the same keys.\",\n                    key, existingValue, newValue));\n          }\n        }\n      }\n\n      // Merge properties: new properties are added to existing ones\n      Properties merged = new Properties();\n      merged.putAll(existing);\n      merged.putAll(properties);\n      return toBuilder().properties(merged).build();\n    }\n\n    /** Builder for {@link Write}. */\n    @AutoValue.Builder","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/clickhouse/src/main/java/org/apache/beam/sdk/io/clickhouse/ClickHouseIO.java#L410-L446","documentation":"ClickHouseIO.Write.withProperties detects when a property being set conflicts with one already derived from the JDBC URL. If the same key exists in both places with different values, the builder throws IllegalArgumentException with a formatted message naming the key and both values, preventing ambiguous connection configuration where one source silently overrides the other.","triggerScenarios":"Setting e.g. withProperties({\"user\": \"alice\"}) while the JDBC URL already embeds user=bob — any key present in both the parsed URL properties and the Properties argument with unequal values triggers the throw.","commonSituations":"Credentials or settings duplicated between a URL string pasted from one environment and a Properties file maintained separately; environment-specific URLs carrying properties that a shared code path also sets; someone adds a property to withProperties without realizing the URL already defines it.","solutions":["Remove the duplicated key from either the JDBC URL or the withProperties call so each key is set in exactly one place","Make the values identical if both sources must carry the key","Parse your JDBC URL (ClickHouseJdbcUrlParser.parse) and merge programmatically, letting the URL win or explicitly overriding, before calling withProperties","Log the effective properties at startup to catch duplication early"],"exampleFix":"// before\nString url = \"jdbc:clickhouse://host:8123/db?user=bob\";\nprops.setProperty(\"user\", \"alice\"); // conflict\n// after\nremove \"user=bob\" from the URL, or set props \"user\" to \"bob\" to match","handlingStrategy":"validation","validationCode":"ParsedJdbcUrl parsed = ClickHouseJdbcUrlParser.parse(jdbcUrl);\nfor (String key : userProps.stringPropertyNames()) {\n  String urlVal = parsed.getProperties().getProperty(key);\n  if (urlVal != null && !urlVal.equals(userProps.getProperty(key))) {\n    throw new IllegalArgumentException(\"Duplicate property in URL and withProperties: \" + key);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  writer = writer.withProperties(props);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Property conflict\")) { LOG.error(\"Remove the duplicated key from the JDBC URL or withProperties\"); }\n  throw e;\n}","preventionTips":["Keep each connection setting in exactly one place — URL or Properties, not both","Parse the JDBC URL at startup and log effective properties to spot duplication","Standardize on URL-embedded properties (or Properties only) across environments"],"tags":["java","clickhouse","beam","jdbc","config-conflict"],"backgroundTag":"conflicting-config-options","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}