{"record":{"id":"eeeb254695ebc518","repo":"quarkusio/quarkus","slug":"failed-to-convert-rest-client-url-to-uri","errorCode":null,"errorMessage":"Failed to convert REST client URL to URI","messagePattern":"Failed to convert REST client URL to URI","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java","lineNumber":114,"sourceCode":"\n    private ClientLogger clientLogger;\n    private LoggingScope loggingScope;\n    private Integer loggingBodyLimit;\n    private Set<String> maskedHeaders;\n\n    private Boolean trustAll;\n    private String userAgent;\n    private Boolean disableDefaultMapper;\n    private Boolean enableCompression;\n    private String domainSocketPath;\n    private Consumer<HttpClientOptions> clientOptionsCustomizer;\n\n    @Override\n    public RestClientBuilderImpl baseUrl(URL url) {\n        try {\n            this.uri = url.toURI();\n        } catch (URISyntaxException e) {\n            throw new IllegalArgumentException(\"Failed to convert REST client URL to URI\", e);\n        }\n        return this;\n    }\n\n    @Override\n    public RestClientBuilderImpl connectTimeout(long timeout, TimeUnit timeUnit) {\n        clientBuilder.connectTimeout(timeout, timeUnit);\n        return this;\n    }\n\n    @Override\n    public RestClientBuilderImpl readTimeout(long timeout, TimeUnit timeUnit) {\n        clientBuilder.readTimeout(timeout, timeUnit);\n        return this;\n    }\n\n    public RestClientBuilderImpl tlsConfiguration(TlsConfiguration tlsConfiguration) {\n        clientBuilder.tlsConfig(new TlsConfig() {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java#L96-L132","documentation":"RestClientBuilderImpl.baseUrl(URL) converts the java.net.URL to a java.net.URI to store internally. URL.toURI() throws URISyntaxException when the URL is not a valid URI (illegal characters, spaces, missing scheme, etc.); the builder wraps it in this IllegalArgumentException. Underlying MP Rest Client requires an absolute, syntactically valid base URI.","triggerScenarios":"Calling builder.baseUrl(new URL(...)) with a URL containing spaces or other illegal characters, a relative URL, or one whose scheme/authority is malformed so URL.toURI() fails.","commonSituations":"Base URL read from config with an unencoded space or query string; URL constructed by string concatenation with typos (missing scheme like 'example.com/api'); non-ASCII hostnames not IDN-encoded.","solutions":["Fix or sanitize the URL string before constructing it (encode spaces, add scheme)","Use builder.baseUri(URI.create(...)) and validate the URI up front","Trim/truncate the config value — often a trailing newline/space or truncated env var causes the syntax error"],"exampleFix":"// before\nbuilder.baseUrl(new URL(configUrl.trim()));\n// after\nURI uri = URI.create(configUrl.trim());\nif (!uri.isAbsolute()) throw new IllegalArgumentException(\"URL must be absolute: \" + configUrl);\nbuilder.baseUri(uri);","handlingStrategy":"validation","validationCode":"static URI toSafeUri(String raw) {\n    String cleaned = raw == null ? \"\" : raw.trim().replace(\" \", \"%20\");\n    URI uri = URI.create(cleaned);\n    if (!uri.isAbsolute()) throw new IllegalArgumentException(\"Base URL must be absolute: \" + raw);\n    return uri;\n}","typeGuard":"static boolean isAbsoluteHttpUrl(String s) {\n    try { URI u = new URI(s.trim()); return (\"http\".equalsIgnoreCase(u.getScheme()) || \"https\".equalsIgnoreCase(u.getScheme())) && u.getHost() != null; }\n    catch (URISyntaxException e) { return false; }\n}","tryCatchPattern":"try {\n    builder.baseUrl(new URL(rawUrl));\n} catch (IllegalArgumentException e) {\n    throw new ConfigurationException(\"Invalid base URL: \" + rawUrl, e);\n}","preventionTips":["Trim and URL-encode config-derived base URLs before use","Prefer baseUri(URI.create(...)) so failures surface at URI.create time with clearer messages","Never build base URLs by naive string concatenation; validate scheme and host presence"],"tags":["rest-client","url","uri-syntax"],"backgroundTag":"invalid-url","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}