{"record":{"id":"77604098245ebb0f","repo":"stanfordnlp/CoreNLP","slug":"could-not-parse-url-uri","errorCode":null,"errorMessage":"Could not parse URL: ${uri}","messagePattern":"Could not parse URL: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/pipeline/WebServiceAnnotator.java","lineNumber":200,"sourceCode":"\n  /**\n   * A utility to ping an endpoint. Useful for {@link #live()} and {@link #ready(boolean initialTest)}.\n   *\n   * @param uri The URL we are trying to ping.\n   *\n   * @return True if we got any non-5XX response from the endpoint.\n   */\n  protected boolean ping(String uri) {\n    try {\n      URL url = new URL(uri);\n      HttpURLConnection connection = (HttpURLConnection) url.openConnection();\n      connection.setRequestProperty(\"Accept-Charset\", \"UTF-8\");\n      connection.setRequestMethod(\"GET\");\n      connection.connect();\n      int code = connection.getResponseCode();\n      return code < 500 || code >= 600;\n    } catch (MalformedURLException e) {\n      log.warn(\"Could not parse URL: \" + uri);\n      return false;\n    } catch (ClassCastException e) {\n      log.warn(\"Not an HTTP URI\");\n      return false;\n    } catch (IOException e) {\n      return false;\n    }\n\n  }\n\n\n  /**\n   * Start the actual server.\n   *\n   * @param command the command we are using to start the sever.\n   *\n   * @return True if the server was started; false otherwise.\n   */","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/WebServiceAnnotator.java#L182-L218","documentation":"WebServiceAnnotator.ping() validates that the configured server URI is reachable before annotating. When the URI string is malformed (cannot be converted to a URL), a MalformedURLException is caught and a warning is logged, and ping returns false so the annotator reports itself not ready.","triggerScenarios":"Calling ready() or annotateImpl() when the `uri` option (e.g. serverUrl) is not a parseable absolute URL, such as a missing scheme (\"localhost:9000\"), illegal characters, or empty string.","commonSituations":"Setting webservice annotator properties with a typo in the URL, forgetting http:// prefix, using a relative path, or environment-specific config pointing at an unparseable endpoint.","solutions":["Fix the `uri` property to a fully qualified absolute URL, e.g. http://host:port.","Start the web service server and confirm the endpoint exists before running the pipeline.","Log/print the configured URI value to spot typos or unresolved property substitution.","If the URI comes from properties/environment, validate it with new URI(...) or URL parsing before constructing the annotator."],"exampleFix":"// before\nprops.setProperty(\"webservice.uri\", \"localhost:9000\");\n// after\nprops.setProperty(\"webservice.uri\", \"http://localhost:9000\");","handlingStrategy":"validation","validationCode":"try { new java.net.URL(uri); if (!uri.startsWith(\"http\")) throw new IllegalArgumentException(\"uri must be http(s)\"); } catch (java.net.MalformedURLException e) { throw new IllegalArgumentException(\"Bad service uri: \" + uri); }","typeGuard":null,"tryCatchPattern":"if (!annotator.ready()) { log.warn(\"Service unreachable or bad URI: \" + uri); return fallbackAnnotate(input); }","preventionTips":["Always use fully qualified http(s):// URLs in annotator properties","Ping the service endpoint before running the full pipeline","Externalize the URI to one validated config location"],"tags":["network","url","configuration"],"backgroundTag":"invalid-url-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}