quarkusio/quarkus · info · IllegalArgumentException

Currently only 'fruitsFindBy?type=name' is supported

Error message

Currently only 'fruitsFindBy?type=name' is supported

What it means

The private findBy() helper in this test FruitResource only supports lookup by fruit name via the named query 'Fruits.findByName'. Any other 'type' query parameter is rejected with an IllegalArgumentException, which JAX-RS maps to a 500 response unless handled. It is an intentional guard in a multitenancy integration test resource, not a framework error.

Source

Thrown at integration-tests/hibernate-orm-tenancy/datasource/src/main/java/io/quarkus/it/hibernate/multitenancy/fruit/FruitResource.java:166

        entityManager.remove(fruit);
        return Response.status(204).build();
    }

    @GET
    @Path("fruitsFindBy")
    public Response findByDefault(@NotNull @QueryParam("type") String type, @NotNull @QueryParam("value") String value) {
        return findBy(type, value);
    }

    @GET
    @Path("{tenant}/fruitsFindBy")
    public Response findByTenant(@NotNull @QueryParam("type") String type, @NotNull @QueryParam("value") String value) {
        return findBy(type, value);
    }

    private Response findBy(@NotNull String type, @NotNull String value) {
        if (!"name".equalsIgnoreCase(type)) {
            throw new IllegalArgumentException("Currently only 'fruitsFindBy?type=name' is supported");
        }
        List<Fruit> list = entityManager.createNamedQuery("Fruits.findByName", Fruit.class).setParameter("name", value)
                .getResultList();
        if (list.size() == 0) {
            return Response.status(404).build();
        }
        Fruit fruit = list.get(0);
        return Response.status(200).entity(fruit).build();
    }

    @Provider
    public static class ErrorMapper implements ExceptionMapper<Exception> {

        @Override
        public Response toResponse(Exception exception) {
            LOG.error("Failed to handle request", exception);

            int code = 500;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Use type=name in the query string (e.g. ?type=name&value=Apple).
  2. If you need another filter type, add a branch in findBy() for it with a corresponding named query.
  3. Wrap the call and map IllegalArgumentException to a 400 response via an ExceptionMapper.

Example fix

// before
if (!"name".equalsIgnoreCase(type)) {
    throw new IllegalArgumentException("Currently only 'fruitsFindBy?type=name' is supported");
}
// after
if ("color".equalsIgnoreCase(type)) {
    list = entityManager.createNamedQuery("Fruits.findByColor", Fruit.class).setParameter("color", value).getResultList();
} else if (!"name".equalsIgnoreCase(type)) {
    return Response.status(400).entity("Unsupported type").build();
}
Defensive patterns

Strategy: validation

Validate before calling

if (!"name".equalsIgnoreCase(type)) {
    throw new IllegalArgumentException("Only type=name is supported; got: " + type);
}

Try / catch

try {
    Response r = resource.findByTenant(type, value);
} catch (IllegalArgumentException e) {
    // fall back to type=name or surface a 400 to the caller
}

Prevention

When it happens

Trigger: Calling GET fruitsFindBy with type != "name" (e.g. ?type=color&value=red) on either the default-tenant or tenant-scoped endpoint of integration-tests/hibernate-orm-tenancy/datasource.

Common situations: Extending the test endpoint with new filter types and forgetting to update this if-check; calling the endpoint with a misspelled or uppercase-sensitive assumption about the type param; curl/REST-client tests passing an unsupported filter.

Related errors


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