languagetool-org/languagetool · error · RuntimeException
URL does not seem to be a valid Wikipedia URL: + url
Error message
URL does not seem to be a valid Wikipedia URL: + url
What it means
WikipediaQuickCheck validates the given URL against regular expressions for regular and secure (https) Wikipedia URLs. If neither matches, getUrlMatcher throws a RuntimeException stating the URL does not look like a valid Wikipedia URL.
Source
Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java:111
public Language getLanguage(URL url) {
Matcher matcher = getUrlMatcher(url.toString());
return Languages.getLanguageForShortCode(matcher.group(1));
}
public String getPageTitle(URL url) {
Matcher matcher = getUrlMatcher(url.toString());
return matcher.group(2);
}
private Matcher getUrlMatcher(String url) {
Matcher matcher1 = WIKIPEDIA_URL_REGEX.matcher(url);
Matcher matcher2 = SECURE_WIKIPEDIA_URL_REGEX.matcher(url);
if (matcher1.matches()) {
return matcher1;
} else if (matcher2.matches()) {
return matcher2;
}
throw new RuntimeException("URL does not seem to be a valid Wikipedia URL: " + url);
}
public void setDisabledRuleIds(List<String> ruleIds) {
disabledRuleIds = ruleIds;
}
public List<String> getDisabledRuleIds() {
return disabledRuleIds;
}
public MarkupAwareWikipediaResult checkPage(URL url) throws IOException, PageNotFoundException {
return checkPage(url, null);
}
/**
* @since 2.6
*/
public MarkupAwareWikipediaResult checkPage(URL url, ErrorMarker errorMarker) throws IOException, PageNotFoundException {View on GitHub (pinned to 2e990059ce)
Solutions
- Use a standard Wikipedia URL of the form http(s)://<lang>.wikipedia.org/...
- Check for typos in the URL/domain
- Update the SECURE/regular Wikipedia URL regex patterns to cover the URL form you use
- Pre-validate the URL against the supported pattern in your own code before calling
Example fix
// before String url = "https://de.wiktionary.org/wiki/Haus"; // after String url = "https://de.wikipedia.org/wiki/Haus";
Defensive patterns
Strategy: validation
Validate before calling
private static final Pattern WIKI = Pattern.compile("https?://[a-z-]+\\.wikipedia\\.org/.*");
if (url == null || !WIKI.matcher(url).matches()) throw new IllegalArgumentException("not a wikipedia URL"); Type guard
boolean isWikipediaUrl(String url) { return url != null && WIKIPEDIA_URL_REGEX.matcher(url).matches(); } Try / catch
try {
Matcher m = quickCheck.getUrlMatcher(url);
} catch (RuntimeException e) {
System.err.println("Please provide a URL like https://en.wikipedia.org/wiki/...");
} Prevention
- Only pass *.wikipedia.org URLs (not other Wikimedia projects)
- Sanitize URLs copied from browsers (strip anchors/extra params if unsupported)
- Re-check regex coverage when new Wikipedia URL forms appear
When it happens
Trigger: Passing a non-Wikipedia URL, a URL with an unexpected host pattern (e.g. wikimedia project other than wikipedia, mobile domain, or missing language subdomain) to the quick-check entry point.
Common situations: Using https://simple.wiktionary.org or another Wikimedia project instead of *.wikipedia.org; typos in the domain; very new domain forms not covered by the bundled regexes.
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
- Got " + matcher.groupCount() + " groups for regex '" + patte
- Got " + matcher.groupCount() + " groups for regex '" + patte
- suppressMisspelledMatch must be a valid regex
- suppressMisspelledSuggestions must be a valid regex
- Error analyzing sentence: '${sentence}' with rule ${rule.get
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/4ccb7e48fe650ce2.
Report an issue: GitHub.