{"record":{"id":"aa127973bb379684","repo":"apache/beam","slug":"error-creating-uri-providedurl-from-a-list-of-providedurls","errorCode":null,"errorMessage":"Error creating URI '\" + providedUrl + \"' from a list of \" + providedUrls.size() + \" URLs","messagePattern":"Error creating URI '\" \\+ providedUrl \\+ \"' from a list of \" \\+ providedUrls\\.size\\(\\) \\+ \" URLs","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/neo4j/src/main/java/org/apache/beam/sdk/io/neo4j/Neo4jIO.java","lineNumber":398,"sourceCode":"\n      // Get the list of the URI to connect with\n      //\n      List<URI> uris = new ArrayList<>();\n      String url = getProvidedValue(getUrl());\n      if (url != null) {\n        try {\n          uris.add(new URI(url));\n        } catch (URISyntaxException e) {\n          throw new RuntimeException(\"Error creating URI from URL '\" + url + \"'\", e);\n        }\n      }\n      List<String> providedUrls = getProvidedValue(getUrls());\n      if (providedUrls != null) {\n        for (String providedUrl : providedUrls) {\n          try {\n            uris.add(new URI(providedUrl));\n          } catch (URISyntaxException e) {\n            throw new RuntimeException(\n                \"Error creating URI '\"\n                    + providedUrl\n                    + \"' from a list of \"\n                    + providedUrls.size()\n                    + \" URLs\",\n                e);\n          }\n        }\n      }\n\n      // A specific routing driver can be used to connect to specific clustered configurations.\n      // Often we don't need it because the Java driver automatically can figure this out\n      // automatically. To keep things simple we use the routing driver in case we have more\n      // than one URL specified.  This is an exceptional case.\n      //\n      Driver driver;\n      AuthToken authTokens =\n          getAuthToken(getProvidedValue(getUsername()), getProvidedValue(getPassword()));","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/neo4j/src/main/java/org/apache/beam/sdk/io/neo4j/Neo4jIO.java#L380-L416","documentation":"Same URI parsing as the single-URL case, but for the URL list supplied via .withUrls(...). One entry in the list fails new URI(...) and buildDriver throws a RuntimeException naming the bad entry and the total list size, so you can find which of N configured servers is malformed.","triggerScenarios":"Passing a list of cluster addresses via .withUrls(Arrays.asList(...)) where at least one entry lacks a valid scheme or contains illegal characters; executed during expand -> buildDriver when creating the Neo4j driver.","commonSituations":"Comma-separated cluster strings split into entries that keep stray spaces; mixed valid/bolt URLs with an accidental http:// or empty string entry; unresolved placeholders in one of the entries from environment config.","solutions":["Fix the named entry to a valid URI with scheme, e.g. neo4j+s://host:7687.","Sanitize the list before building: filter/split on commas and trim each entry, dropping blanks.","Pre-validate every entry with URI.create(entry) in your pipeline setup to fail with your own clearer message.","Check env/config interpolation so no entry remains an unresolved placeholder like ${NEO4J_URL_2}."],"exampleFix":"// before\n.withUrls(Arrays.asList(\" neo4j://a:7687\", \"b:7687\"))\n// after\n.withUrls(Arrays.asList(\"neo4j://a:7687\", \"neo4j://b:7687\"))","handlingStrategy":"validation","validationCode":"List<String> urls = getProvidedValue(getUrls());\nif (urls != null) {\n  for (String u : urls) {\n    try { new URI(u); } catch (URISyntaxException e) {\n      throw new IllegalArgumentException(\"Invalid neo4j URL in list: '\" + u + \"'\");\n    }\n  }\n}","typeGuard":"static List<URI> parseUrls(List<String> urls) {\n  return urls.stream().map(String::trim).filter(s -> !s.isEmpty()).map(u -> {\n    try { return new java.net.URI(u); } catch (URISyntaxException e) { throw new IllegalArgumentException(u, e); }\n  }).collect(java.util.stream.Collectors.toList());\n}","tryCatchPattern":"try {\n  pipeline.apply(Neo4jIO.read()...);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Error creating URI\")) {\n    throw new IllegalArgumentException(\"One of the withUrls entries is malformed: \" + e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Split comma-separated cluster strings on ',' and trim each entry.","Filter out empty strings before passing the list.","Validate every cluster URL at startup, failing with the offending value."],"tags":["neo4j","apache-beam","uri","url"],"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"}