apache/dolphinscheduler · error · IllegalArgumentException
url: %s is invalid
Error message
url: %s is invalid
What it means
addUrlParams() parses the given URL with OkHttp's HttpUrl.parse before appending query parameters; HttpUrl.parse returns null for malformed URLs, and this IllegalArgumentException is thrown in response. It means the URL string supplied to a GET/POST-with-params helper is not a valid absolute HTTP(S) URL.
Source
Thrown at dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OkHttpUtils.java:160
OkHttpClient client = getHttpClient(connectTimeout, writeTimeout, readTimeout);
Request.Builder requestBuilder = new Request.Builder().url(url);
addHeader(okHttpRequestHeaders.getHeaders(), requestBuilder);
requestBuilder = requestBuilder.delete();
try (Response response = client.newCall(requestBuilder.build()).execute()) {
return new OkHttpResponse(response.code(), getResponseBody(response));
} catch (Exception e) {
throw new RuntimeException(String.format("Delete request execute failed, url: %s", url), e);
}
}
private static String addUrlParams(@Nullable Map<String, Object> requestParams, @NonNull String url) {
if (requestParams == null) {
return url;
}
HttpUrl httpUrl = HttpUrl.parse(url);
if (httpUrl == null) {
throw new IllegalArgumentException(String.format("url: %s is invalid", url));
}
HttpUrl.Builder urlBuilder = httpUrl.newBuilder();
for (Map.Entry<String, Object> entry : requestParams.entrySet()) {
urlBuilder.addQueryParameter(entry.getKey(), entry.getValue().toString());
}
return urlBuilder.toString();
}
private static void addHeader(@Nullable Map<String, String> headers, @NonNull Request.Builder requestBuilder) {
if (headers == null) {
return;
}
headers.forEach(requestBuilder::addHeader);
}
private static String getResponseBody(@NonNull Response response) throws IOException {
if (response.code() != HttpStatus.SC_OK || response.body() == null) {
return String.format("Request execute failed, httpCode: %s, httpBody: %s",View on GitHub (pinned to 02eac45a1b)
Solutions
- Print/inspect the URL argument and confirm it includes a scheme (http:// or https://) and valid host.
- Fix the configuration or caller that builds the URL to always include the scheme.
- Validate the URL with HttpUrl.parse(url) != null before invoking the helper.
- URL-encode any dynamic path segments embedded into the URL string.
Example fix
// before String url = config.getHost() + "/api/items"; // missing scheme // after String url = "https://" + config.getHost() + "/api/items";
Defensive patterns
Strategy: validation
Validate before calling
if (HttpUrl.parse(url) == null) {
throw new IllegalArgumentException("Invalid URL: " + url);
} Try / catch
try {
OkHttpResponse r = OkHttpUtils.get(url, params, headers, timeout);
} catch (IllegalArgumentException e) {
log.error("Bad URL configured: {}", url, e);
} Prevention
- Always store endpoint config with an explicit http(s) scheme.
- Validate configured URLs at startup, not at call time.
- Use HttpUrl.Builder to construct URLs instead of string concatenation.
When it happens
Trigger: Calling OkHttpUtils.get/post (via finalUrl) with a URL that is missing the scheme (e.g. "myhost/api"), contains illegal characters or spaces, or is a relative path, while also passing requestParams so addUrlParams runs.
Common situations: Config value for an API endpoint missing 'http://' or 'https://'; concatenating base path without scheme; typos or unescaped characters in configured URLs; environment-specific config overriding a valid URL with a bad one.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- url can not be null
- Get request execute failed, url: %s
- Post request execute failed, url: %s
- Put request execute failed, url: %s
- Delete request execute failed, url: %s
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/946914792d137758.
Report an issue: GitHub.