{"record":{"id":"644a833723f41fbf","repo":"eclipse-vertx/vert.x","slug":"invalid-url-644a83","errorCode":null,"errorMessage":"Invalid url: ","messagePattern":"Invalid url: ","errorType":"exception","errorClass":"VertxException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/http/RequestOptions.java","lineNumber":313,"sourceCode":"   * e.g. {@code Future<HttpClientResponse>} or {@code Future<Buffer>} response body.\n   *\n   * <p/>The timeout starts after a connection is obtained from the client, similar to calling\n   * {@link HttpClientRequest#idleTimeout(long)}.\n   *\n   * @param timeout the amount of time in milliseconds.\n   * @return a reference to this, so the API can be used fluently\n   */\n  public RequestOptions setIdleTimeout(long timeout) {\n    this.idleTimeout = timeout;\n    return this;\n  }\n\n  private URL parseUrl(String surl) {\n    // Note - parsing a URL this way is slower than specifying host, port and relativeURI\n    try {\n      return new URL(surl);\n    } catch (MalformedURLException e) {\n      throw new VertxException(\"Invalid url: \" + surl, e);\n    }\n  }\n\n  /**\n   * Parse an absolute URI to use, this will update the {@code ssl}, {@code host},\n   * {@code port} and {@code uri} fields.\n   *\n   * @param absoluteURI the uri to use\n   * @return a reference to this, so the API can be used fluently\n   */\n  public RequestOptions setAbsoluteURI(String absoluteURI) {\n    Objects.requireNonNull(absoluteURI, \"Cannot set a null absolute URI\");\n    URL url = parseUrl(absoluteURI);\n    return setAbsoluteURI(url);\n  }\n\n  /**\n   * Like {@link #setAbsoluteURI(String)} but using an {@link URL} parameter.","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/http/RequestOptions.java#L295-L331","documentation":"RequestOptions.parseUrl wraps java.net.URL construction failures. When an absolute URL string set via setAbsoluteURL (or routed through the url(String) option) cannot be parsed as a well-formed URL, Vert.x throws this VertxException wrapping the underlying MalformedURLException. It means the URL string itself is malformed — missing protocol, illegal characters, or unsupported scheme.","triggerScenarios":"Calling RequestOptions.setAbsoluteURL(String) with a string like \"localhost:8080/path\" (no scheme), \"http://\" (empty host), or a URL containing spaces or other illegal characters; the resulting options are then used to build an HttpClientRequest.","commonSituations":"Building the URL by string concatenation and forgetting the 'http://' prefix; user-supplied URLs passed through unvalidated; environment-specific config where the scheme was dropped; copying a URI containing non-ASCII characters without encoding.","solutions":["Ensure the URL string includes a valid scheme and host, e.g. 'http://host:port/path'.","Pre-validate with new java.net.URL(s) in a try/catch or use URI.create before passing to setAbsoluteURL.","Encode illegal characters with URLEncoder/URI multi-argument constructor instead of raw string interpolation.","Alternatively specify host, port, and URI separately via setHost/setPort/setURI to avoid full-URL parsing."],"exampleFix":"// before\nRequestOptions opts = new RequestOptions().setAbsoluteURL(baseHost + \":8080/api\");\n// after\nRequestOptions opts = new RequestOptions().setAbsoluteURL(\"http://\" + baseHost + \":8080/api\");","handlingStrategy":"validation","validationCode":"static boolean isValidUrl(String s) {\n  try { new java.net.URL(s); return true; } catch (MalformedURLException e) { return false; }\n}\n// use: if (!isValidUrl(url)) throw new IllegalArgumentException(\"bad url: \" + url);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include scheme and host when constructing URLs by concatenation.","Encode query/path parameters with URLEncoder before interpolation.","Prefer RequestOptions setHost/setPort/setURI over full-URL strings."],"tags":["url","http-client","malformed-url"],"backgroundTag":"invalid-url","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}