{"record":{"id":"7bf2588e4b8c3a07","repo":"apache/beam","slug":"error-creating-uri-from-url-url","errorCode":null,"errorMessage":"Error creating URI from URL '\" + url + \"'","messagePattern":"Error creating URI from URL '\" \\+ url \\+ \"'","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":389,"sourceCode":"      }\n      // We're trying to work around a subtle serialisation bug in the Neo4j Java driver.\n      // The fix is work in progress.  For now, we harden our code to avoid\n      // wild goose chases.\n      //\n      Boolean hasDefaultConfig = getProvidedValue(getHasDefaultConfig());\n      if (hasDefaultConfig != null && hasDefaultConfig) {\n        config = Config.defaultConfig();\n      }\n\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      }","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/neo4j/src/main/java/org/apache/beam/sdk/io/neo4j/Neo4jIO.java#L371-L407","documentation":"buildDriver parses the single URL given via .withUrl(...) into a java.net.URI. If the string is not a syntactically valid URI (URISyntaxException), it wraps the failure in a RuntimeException with the offending URL. The Neo4j driver cannot be built without at least one valid routing/bolt URI.","triggerScenarios":"Calling .withUrl(\"localhost:7687\") or withUrl(\"http://myhost\") etc. — missing the neo4j://, neo4j+s://, bolt:// scheme, or containing spaces/illegal characters — during expand -> buildDriver.","commonSituations":"Typing the host without the bolt:// or neo4j:// scheme; pasting an HTTP browser URL instead of the bolt address; environment-specific placeholders like ${NEO4J_URL} left unresolved; trailing whitespace or quotes from config files.","solutions":["Use a fully qualified scheme URL: .withUrl(\"neo4j://hostname:7687\") or bolt://hostname:7687.","Trim whitespace and remove stray quotes/brackets from the URL before passing it.","Validate locally: new URI(url) in a unit test, or pre-validate with URI.create and catch IllegalArgumentException early.","If the URL comes from options/env, log or fail fast at setup with a clear message when the placeholder is unresolved."],"exampleFix":"// before\n.withUrl(\"localhost:7687\")\n// after\n.withUrl(\"neo4j://localhost:7687\")","handlingStrategy":"validation","validationCode":"String url = getProvidedValue(getUrl());\nif (url != null) {\n  try { new URI(url); } catch (URISyntaxException e) {\n    throw new IllegalArgumentException(\"neo4j url must include a scheme, e.g. neo4j://host:7687, got: \" + url);\n  }\n}","typeGuard":"static boolean isValidNeo4jUrl(String url) {\n  try { new java.net.URI(url); return url.startsWith(\"neo4j\") || url.startsWith(\"bolt\"); }\n  catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n  pipeline.apply(Neo4jIO.read()...);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Error creating URI from URL\")) {\n    throw new IllegalArgumentException(\"Fix the neo4j URL: include scheme neo4j:// or bolt://\");\n  }\n  throw e;\n}","preventionTips":["Always include the scheme: neo4j://, neo4j+s://, or bolt://.","Validate URLs from env/config at application startup with URI.create.","Trim and strip quotes from config-injected values."],"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"}