{"record":{"id":"fa7a79cf5cb24b2d","repo":"flowable/flowable-engine","slug":"invalid-url-exception-occurred-fa7a79","errorCode":null,"errorMessage":"Invalid URL exception occurred","messagePattern":"Invalid URL exception occurred","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-http-common/src/main/java/org/flowable/http/common/impl/spring/reactive/SpringWebClientFlowableHttpClient.java","lineNumber":171,"sourceCode":"                case \"HEAD\": {\n                    headersSpec = webClient.head().uri(uri);\n                    break;\n                }\n                case \"OPTIONS\": {\n                    headersSpec = webClient.options().uri(uri);\n                    break;\n                }\n                default: {\n                    throw new FlowableException(requestInfo.getMethod() + \" HTTP method not supported\");\n                }\n            }\n\n            setHeaders(headersSpec, requestInfo.getHttpHeaders());\n            setHeaders(headersSpec, requestInfo.getSecureHttpHeaders());\n\n            return new WebClientExecutableHttpRequest(headersSpec, !requestInfo.isNoRedirects());\n        } catch (URISyntaxException ex) {\n            throw new FlowableException(\"Invalid URL exception occurred\", ex);\n        }\n    }\n\n    public static boolean shouldFollowRedirect(HttpClientRequest request, HttpClientResponse response) {\n        boolean followRedirect = request.currentContextView().getOrDefault(FOLLOW_REDIRECT_CONTEXT_KEY, Boolean.FALSE);\n        int statusCode = response.status().code();\n        return followRedirect && statusCode >= 300 && statusCode < 400;\n    }\n\n    protected WebClient determineWebClient(HttpRequest requestInfo) {\n        if (requestInfo.getTimeout() <= 0) {\n            return webClient;\n        }\n\n        Duration requestTimeout = Duration.ofMillis(requestInfo.getTimeout());\n        if (requestTimeout.equals(initialRequestTimeout)) {\n            // If the request timeout is the same as the initial request timeout then there is nothing to do\n            return webClient;","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-http-common/src/main/java/org/flowable/http/common/impl/spring/reactive/SpringWebClientFlowableHttpClient.java#L153-L189","documentation":"prepareRequest builds a java.net.URI from the request info; if the URL string is malformed, URISyntaxException is thrown and re-wrapped as this FlowableException. The library throws it because Spring WebClient requires a syntactically valid URI before any request can be prepared.","triggerScenarios":"Setting a request URL containing illegal characters (spaces, unencoded braces, non-ASCII chars), a missing scheme (e.g. 'example.com/api' instead of 'https://example.com/api'), or interpolating a null/empty host from a process variable.","commonSituations":"HTTP task URL assembled from process variables with unencoded query values; missing 'https://' prefix in config; copy-pasted URL with spaces; special characters like '|' or '{' in query parameters.","solutions":["Fix the URL string so it is a valid absolute URI (include scheme, encode path/query with URLEncoder or UriComponentsBuilder).","Validate the URL at configuration time using 'new URI(url)' in a try block before wiring it into the HTTP task.","If the URL is dynamic, sanitize/encode variable values before they reach the request info."],"exampleFix":"// before\nrequestInfo.setUrl(base + \"/search?q=\" + term);\n\n// after\nrequestInfo.setUrl(base + \"/search?q=\" + URLEncoder.encode(term, StandardCharsets.UTF_8));","handlingStrategy":"validation","validationCode":"try {\n    new java.net.URI(url);\n} catch (java.net.URISyntaxException e) {\n    throw new IllegalArgumentException(\"Invalid HTTP task URL: \" + url, e);\n}\nif (!url.startsWith(\"http://\") && !url.startsWith(\"https://\")) {\n    throw new IllegalArgumentException(\"URL must be absolute http(s): \" + url);\n}","typeGuard":null,"tryCatchPattern":"try {\n    client.prepareRequest(requestInfo);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"Invalid URL\")) {\n        logger.error(\"Bad URL configured: {}\", requestInfo.getUrl(), e.getCause());\n    }\n}","preventionTips":["URL-encode all dynamic path/query segments (URLEncoder or UriComponentsBuilder).","Always include the scheme; validate URLs at config load time with new URI(...)."],"tags":["http","url","uri-syntax","webclient"],"backgroundTag":"invalid-url-format","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}