languagetool-org/languagetool · error · IllegalArgumentException
Could not parse provided serverURL: ''
Error message
Could not parse provided serverURL: ''
What it means
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.
Source
Thrown at languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java:635
* @since 4.8
* @return prefix / base URL for API requests
*/
@Nullable
public URI getServerURL() {
return serverURL;
}
/**
* @since 4.8
* @param url prefix / base URL for API requests
*/
public void setServerURL(@Nullable String url) {
if (url != null) {
try {
// ignore different protocols, ports,... just use path for relative requests
serverURL = new URI(new URI(url).getPath());
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Could not parse provided serverURL: '" + url + "'", e);
}
} else {
serverURL = null;
}
}
/**
* @param len the maximum text length allowed (in number of characters), texts that are longer
* will cause an exception when being checked, unless the user can provide
* an API key
*/
public void setMaxTextLengthAnonymous(int len) {
this.maxTextLengthAnonymous = len;
}
public void setMaxTextLengthLoggedIn(int len) {
this.maxTextLengthLoggedIn = len;
}View on GitHub (pinned to 2e990059ce)
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
Example fix
// before --serverURL http://my server/lt // after --serverURL http://myserver/lt
Defensive patterns
Strategy: validation
Validate before calling
try {
new URI(new URI(url).getPath());
} catch (URISyntaxException e) {
throw new IllegalStateException("serverURL is not a valid URI: " + url, e);
} Try / catch
try {
config.setServerURL(url);
} catch (IllegalArgumentException e) {
LOG.error("serverURL rejected: {}", e.getMessage());
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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`.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- No rules are active. Please make sure your rule ids (<option
- List of language models is empty
- suppressMisspelledMatch must be a valid regex
- suppressMisspelledSuggestions must be a valid regex
- Could not load simple replacement data from: " + path + ". E
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/cbb66ad0e9fd649b.
Report an issue: GitHub.