quarkusio/quarkus · error · IllegalArgumentException

GeneratedStaticResourceBuildItem endpoint must not end with

Error message

GeneratedStaticResourceBuildItem endpoint must not end with '/': <endpoint>

What it means

GeneratedStaticResourceBuildItem rejects endpoints that end with '/' because resource endpoints map to concrete files, not directories; a trailing slash would create an ambiguous/invalid route. The constructor throws IllegalArgumentException in that case.

Source

Thrown at extensions/vertx-http/deployment-spi/src/main/java/io/quarkus/vertx/http/deployment/spi/GeneratedStaticResourceBuildItem.java:37

 * and {@link io.quarkus.deployment.builditem.GeneratedResourceBuildItem} build items.
 * <br>
 * The value of {@code endpoint} should be prefixed with {@code '/'} and reference a file (no trailing `/`).
 */
public final class GeneratedStaticResourceBuildItem extends MultiBuildItem {

    private final String endpoint;

    private final Path file;
    private final byte[] content;

    private GeneratedStaticResourceBuildItem(final String endpoint, final byte[] content, final Path file) {
        requireNonNull(endpoint, "endpoint is required");
        if (!endpoint.startsWith("/")) {
            throw new IllegalArgumentException(
                    "GeneratedStaticResourceBuildItem endpoint must start with '/': %s".formatted(endpoint));
        }
        if (endpoint.endsWith("/")) {
            throw new IllegalArgumentException(
                    "GeneratedStaticResourceBuildItem endpoint must not end with '/': %s".formatted(endpoint));
        }
        this.endpoint = endpoint;
        this.file = file;
        this.content = content;
    }

    /**
     * The resource will be served at {@code '{quarkus.http.root-path}{endpoint}'}
     *
     * @param endpoint the endpoint from the {@code '{quarkus.http.root-path}'} for this generated static resource. It should be
     *        prefixed with {@code '/'}
     * @param content the content of this generated static resource
     */
    public GeneratedStaticResourceBuildItem(final String endpoint, final byte[] content) {
        this(endpoint, content, null);
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Strip the trailing '/' from the endpoint before constructing the item
  2. Normalize both leading and trailing slashes in one place when generating endpoints
  3. Ensure the endpoint always points to a concrete resource path

Example fix

// before
String ep = "/assets/index.html/";
new GeneratedStaticResourceBuildItem(ep, content)
// after
if (ep.endsWith("/")) { ep = ep.substring(0, ep.length() - 1); }
new GeneratedStaticResourceBuildItem(ep, content)
Defensive patterns

Strategy: validation

Validate before calling

if (endpoint != null && endpoint.endsWith("/")) {
    endpoint = endpoint.substring(0, endpoint.length() - 1);
}

Prevention

When it happens

Trigger: Constructing GeneratedStaticResourceBuildItem with an endpoint like "/assets/" — e.g. derived from a directory path or a URL that kept its trailing slash.

Common situations: Passing directory-style paths from config; copying a route prefix (which may end in '/') into a resource endpoint; trimming the filename but leaving the separator.

Related errors


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