quarkusio/quarkus · error · IllegalArgumentException

The value of URL was invalid ${baseUrl}

Error message

The value of URL was invalid ${baseUrl}

What it means

The fallback branch of configureBaseUrl(): the resolved base URL string could not be parsed by java.net.URL for any reason other than the native https case, so Quarkus wraps it in this IllegalArgumentException keeping the original MalformedURLException as cause.

Source

Thrown at extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java:305

                    String.format(
                            "Unable to determine the proper baseUrl/baseUri. " +
                                    "Consider registering using @RegisterRestClient(baseUri=\"someuri\"), @RegisterRestClient(configKey=\"orkey\"), "
                                    +
                                    "or by adding '%s' or '%s' to your Quarkus configuration",
                            String.format(QUARKUS_CONFIG_REST_URL_FORMAT, propertyPrefix),
                            String.format(QUARKUS_CONFIG_REST_URI_FORMAT, propertyPrefix)));
        }
        String baseUrl = baseUrlOptional.orElse(baseUriFromAnnotation);

        try {
            builder.baseUrl(new URL(baseUrl));
        } catch (MalformedURLException e) {
            if (e.getMessage().contains(
                    "It must be enabled by adding the --enable-url-protocols=https option to the native-image command")) {
                throw new IllegalArgumentException(baseUrl
                        + " requires SSL support but it is disabled. You probably have set quarkus.ssl.native to false.");
            }
            throw new IllegalArgumentException("The value of URL was invalid " + baseUrl, e);
        }
    }

    @SafeVarargs
    private static <T> Optional<T> oneOf(Optional<T>... optionals) {
        for (Optional<T> o : optionals) {
            if (o != null && o.isPresent()) {
                return o;
            }
        }
        return Optional.empty();
    }

    private static OptionalInt oneOf(OptionalInt... optionals) {
        for (OptionalInt o : optionals) {
            if (o != null && o.isPresent()) {
                return o;
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Print/log the resolved property (quarkus.config or ConfigValue lookup) to see the actual runtime value
  2. Fix the URL syntax — it must include the scheme, e.g. https://api.example.com
  3. Check for unexpanded ${placeholders} in profiles and environment overrides
  4. Trim quotes/whitespace, which .properties files may keep literally in some setups

Example fix

// before (application.properties)
quarkus.rest-client.catalog.url=${CATALOG_HOST}/v2   # placeholder unresolved
// after
%prod.quarkus.rest-client.catalog.url=https://catalog.internal:8443/v2
Defensive patterns

Strategy: validation

Validate before calling

// validate URL syntax before handing it to the builder
String url = ConfigProvider.getConfig()
    .getValue("quarkus.rest-client.my-client.url", String.class).trim();
try {
    new java.net.URL(url); // throws MalformedURLException early
} catch (java.net.MalformedURLException e) {
    throw new IllegalStateException("Invalid base URL for my-client: " + url, e);
}

Prevention

When it happens

Trigger: quarkus.rest-client.<key>.url/.uri or @RegisterRestClient(baseUri) contains a malformed value — missing protocol ('api.example.com'), illegal characters, spaces, an unsupported protocol, or a property that interpolated an unresolved placeholder like ${HOST}.

Common situations: Placeholder not expanded because the referenced property does not exist; URL copied with trailing whitespace or surrounding quotes; typo such as 'http:/host'; config value overridden by an env var containing an invalid string.

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/75789e68c10b80a7. Report an issue: GitHub.