quarkusio/quarkus · warning · BadRequestException

Should provide name or color query parameter

Error message

Should provide name or color query parameter

What it means

Same BadRequestException as the java-client variant, thrown by the search endpoint of the elasticsearch-rest-client test resource when neither 'name' nor 'color' query parameters are provided. It is a deliberate client-error guard, not an Elasticsearch failure.

Source

Thrown at integration-tests/elasticsearch-rest-client/src/main/java/io/quarkus/it/elasticsearch/FruitResource.java:54

        return Response.created(URI.create("/fruits/" + fruit.id)).build();
    }

    @GET
    @Path("/{id}")
    public Fruit get(@PathParam("id") String id) throws IOException, ParseException {
        return fruitService.get(id);
    }

    @GET
    @Path("/search")
    public List<Fruit> search(@QueryParam("name") String name, @QueryParam("color") String color)
            throws IOException, ParseException {
        if (name != null) {
            return fruitService.searchByName(name);
        } else if (color != null) {
            return fruitService.searchByColor(color);
        } else {
            throw new BadRequestException("Should provide name or color query parameter");
        }
    }

    @Path("bulk")
    @DELETE
    public Response delete(List<String> identityList) throws IOException {
        fruitService.delete(identityList);
        return Response.ok().build();
    }

    @Path("bulk")
    @POST
    public Response index(List<Fruit> list) throws IOException {
        fruitService.index(list);
        return Response.ok().build();
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Supply ?name=<value> or ?color=<value> on the request.
  2. Correct the client-side parameter names to match the resource signature.
  3. In tests, assert the 400 status when omitting both parameters.

Example fix

// before
GET /fruits/search
// after
GET /fruits/search?color=red
Defensive patterns

Strategy: validation

Validate before calling

if (name == null && color == null) {
    throw new IllegalArgumentException("Provide name or color query parameter");
}

Type guard

null

Try / catch

try {
    Response r = target("/fruits/search").queryParam("color", color).request().get();
} catch (jakarta.ws.rs.BadRequestException e) {
    log.error("Search requires ?name or ?color");
}

Prevention

When it happens

Trigger: GET to the search endpoint with no query parameters or incorrectly named ones (e.g. 'colour', 'fruitName').

Common situations: Manual curl/browser tests without ?name= or ?color=; automated clients with wrong parameter names after an API rename.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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