{"record":{"id":"cbb66ad0e9fd649b","repo":"languagetool-org/languagetool","slug":"could-not-parse-provided-serverurl","errorCode":null,"errorMessage":"Could not parse provided serverURL: ''","messagePattern":"Could not parse provided serverURL: ''","errorType":"console","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java","lineNumber":635,"sourceCode":"   * @since 4.8\n   * @return prefix / base URL for API requests\n   */\n  @Nullable\n  public URI getServerURL() {\n    return serverURL;\n  }\n\n  /**\n   * @since 4.8\n   * @param url prefix / base URL for API requests\n   */\n  public void setServerURL(@Nullable String url) {\n    if (url != null) {\n      try {\n        // ignore different protocols, ports,... just use path for relative requests\n        serverURL = new URI(new URI(url).getPath());\n      } catch (URISyntaxException e) {\n        throw new IllegalArgumentException(\"Could not parse provided serverURL: '\" + url + \"'\", e);\n      }\n    } else {\n      serverURL = null;\n    }\n  }\n\n  /**\n   * @param len the maximum text length allowed (in number of characters), texts that are longer\n   *            will cause an exception when being checked, unless the user can provide\n   *            an API key\n   */\n  public void setMaxTextLengthAnonymous(int len) {\n    this.maxTextLengthAnonymous = len;\n  }\n\n  public void setMaxTextLengthLoggedIn(int len) {\n    this.maxTextLengthLoggedIn = len;\n  }","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java#L617-L653","documentation":"setServerURL accepts an optional URL used for relative request paths (e.g. behind a proxy). The input is parsed as a URI twice; if either parse fails with URISyntaxException, it is rethrown as an IllegalArgumentException wrapping the original exception.","triggerScenarios":"Calling setServerURL with a syntactically invalid URI string — e.g. containing illegal characters, unescaped spaces, or a malformed path — so `new URI(url)` or `new URI(new URI(url).getPath())` throws.","commonSituations":"Reverse-proxy configuration values with spaces or unencoded special characters (`--serverURL http://my server/lt`), trailing config garbage, or missing scheme/typos like `http:/host`.","solutions":["Percent-encode special characters (spaces as %20, etc.) in the serverURL value","Fix the URL syntax — ensure a valid form like `https://host/basepath`","Remove the serverURL option entirely if the default (no relative path prefix) is fine; null is accepted"],"exampleFix":"// before\n--serverURL http://my server/lt\n// after\n--serverURL http://myserver/lt","handlingStrategy":"validation","validationCode":"try {\n  new URI(new URI(url).getPath());\n} catch (URISyntaxException e) {\n  throw new IllegalStateException(\"serverURL is not a valid URI: \" + url, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.setServerURL(url);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"serverURL rejected: {}\", e.getMessage());\n}","preventionTips":["Percent-encode spaces and special characters in the URL","Validate the serverURL value in config linting before startup","Omit the option entirely when no proxy path prefix is needed"],"tags":["configuration","url","parsing"],"backgroundTag":"invalid-url-format","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}