{"record":{"id":"610fddaf72d476a9","repo":"flowable/flowable-engine","slug":"invalid-url-exception-occurred","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/apache/ApacheHttpComponentsFlowableHttpClient.java","lineNumber":233,"sourceCode":"                case \"HEAD\": {\n                    request = new HttpHead(uri);\n                    break;\n                }\n                case \"OPTIONS\":\n                    request = new HttpOptions(uri);\n                    break;\n                default: {\n                    throw new FlowableException(requestInfo.getMethod() + \" HTTP method not supported\");\n                }\n            }\n\n            setHeaders(request, requestInfo.getHttpHeaders());\n            setHeaders(request, requestInfo.getSecureHttpHeaders());\n\n            setConfig(request, requestInfo);\n            return new ApacheHttpComponentsExecutableHttpRequest(request);\n        } catch (URISyntaxException ex) {\n            throw new FlowableException(\"Invalid URL exception occurred\", ex);\n        } catch (IOException ex) {\n            throw new FlowableException(\"IO exception occurred\", ex);\n        }\n    }\n\n    protected URI createUri(String url) throws URISyntaxException {\n        String uri = SPACE_CHARACTER_PATTERN.matcher(url).replaceAll(ENCODED_SPACE_CHARACTER);\n        return new URI(PLUS_CHARACTER_PATTERN.matcher(uri).replaceAll(ENCODED_PLUS_CHARACTER));\n    }\n\n    protected void setRequestEntity(HttpRequest requestInfo, HttpEntityEnclosingRequestBase requestBase) throws UnsupportedEncodingException {\n        if (requestInfo.getBody() != null) {\n            if (StringUtils.isNotEmpty(requestInfo.getBodyEncoding())) {\n                requestBase.setEntity(new StringEntity(requestInfo.getBody(), requestInfo.getBodyEncoding()));\n            } else {\n                requestBase.setEntity(new StringEntity(requestInfo.getBody()));\n            }\n        } else if (requestInfo.getBodyBytes() != null) {","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-http-common/src/main/java/org/flowable/http/common/impl/apache/ApacheHttpComponentsFlowableHttpClient.java#L215-L251","documentation":"prepareRequest converts the configured request URL string into a java.net.URI (createUri). If the URL is syntactically invalid, URISyntaxException is caught and rethrown as FlowableException('Invalid URL exception occurred') with the original exception as cause. The raw URISyntaxException is deliberately wrapped into Flowable's exception hierarchy.","triggerScenarios":"The requestUrl expression resolves to a string that is not a valid URI — illegal characters (spaces handled, but others like '{', '|', unencoded query characters are not), missing scheme, or a malformed URL built from multiple variable parts.","commonSituations":"Concatenating variables into URLs with unencoded special characters (e.g. email addresses, JSON snippets, non-ASCII text); missing 'http://' scheme; template placeholders not fully resolved (leftover ${...} in the string).","solutions":["URL-encode variable parts before inserting them (URLEncoder.encode / URLEncoder.encode(..., StandardCharsets.UTF_8))","Check the cause URISyntaxException in the stack trace for the exact index/character that is invalid","Ensure the URL includes a valid scheme and host; log the resolved URL before the HTTP task","Fix any unresolved ${...} placeholders by setting the missing variables"],"exampleFix":"// before\nString url = \"http://api.example.com/search?q=\" + rawQuery; // rawQuery may contain spaces/special chars\n// after\nString url = \"http://api.example.com/search?q=\" + java.net.URLEncoder.encode(rawQuery, java.nio.charset.StandardCharsets.UTF_8);","handlingStrategy":"validation","validationCode":"try {\n    new java.net.URI(url.replaceAll(\" \", \"%20\").replaceAll(\"\\\\+\", \"%2B\"));\n} catch (java.net.URISyntaxException e) {\n    throw new IllegalArgumentException(\"Invalid request URL: \" + url, e);\n}","typeGuard":"boolean isValidUri(String url) { try { new java.net.URI(url.replaceAll(\" \", \"%20\").replaceAll(\"\\\\+\", \"%2B\")); return true; } catch (Exception e) { return false; } }","tryCatchPattern":"try {\n    client.prepareRequest(requestInfo);\n} catch (FlowableException e) {\n    if (\"Invalid URL exception occurred\".equals(e.getMessage()) && e.getCause() instanceof java.net.URISyntaxException use) {\n        // log use.getIndex() and use.getInput() to locate the bad character\n    } else { throw e; }\n}","preventionTips":["URL-encode every variable interpolated into a URL","Check the URISyntaxException cause for the exact invalid character/index","Verify resolved URLs (with all variables substituted) in integration tests"],"tags":["flowable","url","uri-syntax","http-client"],"backgroundTag":"invalid-url","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"}