quarkusio/quarkus · error · UriBuilderException
empty host
Error message
empty host
What it means
Thrown from buildCharSequence when the builder has an authority component (userInfo, host, or port set) but host is the empty string "". A URI with an authority must have a non-empty host, so building would yield an invalid '//:port' or '//user@' form. It is a UriBuilderException, i.e. the builder state itself is wrong, independent of the template parameters.
Source
Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java:551
boolean encodeSlash) {
return buildCharSequence(paramMap, fromEncodedMap, isTemplate, encodeSlash).toString();
}
private CharSequence buildCharSequence(Map<String, ? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate,
boolean encodeSlash) {
StringBuilder builder = new StringBuilder();
if (scheme != null)
replaceParameter(paramMap, fromEncodedMap, isTemplate, scheme, builder, encodeSlash).append(":");
if (ssp != null) {
builder.append(ssp);
} else if (userInfo != null || host != null || port != -1) {
builder.append("//");
if (userInfo != null)
replaceParameter(paramMap, fromEncodedMap, isTemplate, userInfo, builder, encodeSlash).append("@");
if (host != null) {
if ("".equals(host))
throw new UriBuilderException("empty host");
replaceParameter(paramMap, fromEncodedMap, isTemplate, host, builder, encodeSlash);
}
if (port != -1)
builder.append(":").append(Integer.toString(port));
} else if (authority != null) {
builder.append("//");
replaceParameter(paramMap, fromEncodedMap, isTemplate, authority, builder, encodeSlash);
}
if (path != null) {
StringBuilder tmp = new StringBuilder();
replaceParameter(paramMap, fromEncodedMap, isTemplate, path, tmp, encode, encodeSlash);
if (userInfo != null || host != null) {
if (tmp.length() > 0 && tmp.charAt(0) != '/')
builder.append("/");
}
builder.append(tmp);
}
if (query != null) {View on GitHub (pinned to e1c734241f)
Solutions
- Check what value was passed to UriBuilder.host()/the builder's host field; ensure it is non-empty before build()
- Fix the source of the empty host: config property, env var, or URL-parsing code
- If host is optional, do not call host() at all instead of passing "" — build the authority only when host is present
- Add a guard that rejects blank host strings before configuring the builder
Example fix
// before
String host = config.hostname(); // may be ""
URI uri = UriBuilder.fromScheme("https").host(host).port(8080).build();
// after
String host = config.hostname();
UriBuilder b = UriBuilder.fromUri("https://api.example.com");
if (host != null && !host.isBlank()) { b.host(host); }
URI uri = b.build(); Defensive patterns
Strategy: validation
Validate before calling
if (host == null || host.isBlank()) {
throw new IllegalStateException("Host must be non-empty before building URI");
}
builder.host(host); Type guard
static boolean hasHost(String host) { return host != null && !host.isBlank(); } Try / catch
try {
URI uri = builder.build();
} catch (UriBuilderException e) {
throw new IllegalStateException("Builder misconfigured (empty host/scheme?). Check base URL config.", e);
} Prevention
- Validate base-URL config at startup (fail fast if host part is blank)
- Never call host(""); omit the host() call when there is no host
- Parse base URLs with new URI(...) at config-load time to catch empty authorities early
When it happens
Trigger: Calling UriBuilderImpl.host("") (or host(null) then mutating to empty), or parsing/config loading that sets an empty host, then invoking build()/buildFromMap()/resolveTemplate*.
Common situations: Config property like quarkus.rest-client.url=https://:8080 or an env var HOST="" defaulting to empty; URL parsing code that splits on ':' and yields empty host; programmatic client setup where the host string came from an unset variable.
Related errors
- Specified path can not contain '..' or '%'. Path was
- Specified path is an invalid URI. Path was
- ${exposedEndpoint} is declared by :${endpointConfigs}
- Handler '${handlerClassName}' has not been properly configur
- The value of URL was invalid " + baseUrl
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/114e48fc41954af1.
Report an issue: GitHub.