{"record":{"id":"946914792d137758","repo":"apache/dolphinscheduler","slug":"url-s-is-invalid","errorCode":null,"errorMessage":"url: %s is invalid","messagePattern":"url: (.+?) is invalid","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OkHttpUtils.java","lineNumber":160,"sourceCode":"        OkHttpClient client = getHttpClient(connectTimeout, writeTimeout, readTimeout);\n        Request.Builder requestBuilder = new Request.Builder().url(url);\n        addHeader(okHttpRequestHeaders.getHeaders(), requestBuilder);\n        requestBuilder = requestBuilder.delete();\n        try (Response response = client.newCall(requestBuilder.build()).execute()) {\n            return new OkHttpResponse(response.code(), getResponseBody(response));\n        } catch (Exception e) {\n            throw new RuntimeException(String.format(\"Delete request execute failed, url: %s\", url), e);\n        }\n    }\n\n    private static String addUrlParams(@Nullable Map<String, Object> requestParams, @NonNull String url) {\n        if (requestParams == null) {\n            return url;\n        }\n\n        HttpUrl httpUrl = HttpUrl.parse(url);\n        if (httpUrl == null) {\n            throw new IllegalArgumentException(String.format(\"url: %s is invalid\", url));\n        }\n        HttpUrl.Builder urlBuilder = httpUrl.newBuilder();\n        for (Map.Entry<String, Object> entry : requestParams.entrySet()) {\n            urlBuilder.addQueryParameter(entry.getKey(), entry.getValue().toString());\n        }\n        return urlBuilder.toString();\n    }\n\n    private static void addHeader(@Nullable Map<String, String> headers, @NonNull Request.Builder requestBuilder) {\n        if (headers == null) {\n            return;\n        }\n        headers.forEach(requestBuilder::addHeader);\n    }\n\n    private static String getResponseBody(@NonNull Response response) throws IOException {\n        if (response.code() != HttpStatus.SC_OK || response.body() == null) {\n            return String.format(\"Request execute failed, httpCode: %s, httpBody: %s\",","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OkHttpUtils.java#L142-L178","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nString url = config.getHost() + \"/api/items\"; // missing scheme\n// after\nString url = \"https://\" + config.getHost() + \"/api/items\";","handlingStrategy":"validation","validationCode":"if (HttpUrl.parse(url) == null) {\n    throw new IllegalArgumentException(\"Invalid URL: \" + url);\n}","typeGuard":null,"tryCatchPattern":"try {\n    OkHttpResponse r = OkHttpUtils.get(url, params, headers, timeout);\n} catch (IllegalArgumentException e) {\n    log.error(\"Bad URL configured: {}\", url, e);\n}","preventionTips":["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."],"tags":["http","url","validation","okhttp"],"backgroundTag":"invalid-url","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}