{"record":{"id":"3be8092fe4373d71","repo":"quarkusio/quarkus","slug":"fruit-name-was-not-set-on-request-3be809","errorCode":null,"errorMessage":"Fruit Name was not set on request.","messagePattern":"Fruit Name was not set on request\\.","errorType":"http","errorClass":"WebApplicationException","httpStatus":422,"severity":"error","filePath":"integration-tests/hibernate-search-orm-elasticsearch-tenancy/src/main/java/io/quarkus/it/hibernate/search/orm/elasticsearch/multitenancy/fruit/FruitResource.java","lineNumber":74,"sourceCode":"\n    @POST\n    @Path(\"/\")\n    @Transactional\n    public Response create(@NotNull Fruit fruit) {\n        if (fruit.getId() != null) {\n            throw new WebApplicationException(\"Id was invalidly set on request.\", 422);\n        }\n        LOG.debugv(\"Create {0}\", fruit.getName());\n        entityManager.persist(fruit);\n        return Response.ok(fruit).status(Response.Status.CREATED).build();\n    }\n\n    @PUT\n    @Path(\"/{id}\")\n    @Transactional\n    public Fruit update(@NotNull @PathParam(\"id\") int id, @NotNull Fruit fruit) {\n        if (fruit.getName() == null) {\n            throw new WebApplicationException(\"Fruit Name was not set on request.\", 422);\n        }\n\n        Fruit entity = entityManager.find(Fruit.class, id);\n        if (entity == null) {\n            throw new WebApplicationException(\"Fruit with id of \" + id + \" does not exist.\", 404);\n        }\n        entity.setName(fruit.getName());\n\n        LOG.debugv(\"Update #{0} {1}\", fruit.getId(), fruit.getName());\n\n        return entity;\n    }\n\n    @DELETE\n    @Path(\"/{id}\")\n    @Transactional\n    public Response delete(@NotNull @PathParam(\"id\") int id) {\n        Fruit fruit = entityManager.getReference(Fruit.class, id);","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/hibernate-search-orm-elasticsearch-tenancy/src/main/java/io/quarkus/it/hibernate/search/orm/elasticsearch/multitenancy/fruit/FruitResource.java#L56-L92","documentation":"The PUT update endpoint requires the request body to carry a fruit name; a null name cannot update the entity so the resource fails fast with HTTP 422 (Unprocessable Entity) via WebApplicationException. This is an application-level validation guard, not a framework error.","triggerScenarios":"PUT /fruits/{id} with a JSON body missing the \"name\" field or explicitly containing \"name\": null.","commonSituations":"Frontend partial-update forms that only send changed fields; clients that renamed the JSON property; serialization configured to skip null/empty fields; clients performing a PUT with an empty object {}.","solutions":["Include a non-null \"name\" in the PUT request body","Client-side validate that name is present before sending","Use JSON Patch or a dedicated partial-update DTO if partial updates are intended","Add @NotNull on the entity/DTO field to get standard Bean Validation 400 responses"],"exampleFix":"// before\nPUT /fruits/1\n{}\n\n// after\nPUT /fruits/1\n{\"name\": \"Apple\"}","handlingStrategy":"validation","validationCode":"if (fruit.getName() == null || fruit.getName().isBlank()) {\n    throw new IllegalArgumentException(\"name is required for update\");\n}","typeGuard":"boolean isValidForUpdate(Fruit f) {\n    return f != null && f.getName() != null && !f.getName().isBlank();\n}","tryCatchPattern":"try {\n    Response r = target.path(\"/fruits/\" + id).request().put(Entity.json(fruit));\n    if (r.getStatus() == 422) { /* name missing in payload */ }\n} catch (WebApplicationException e) {\n    if (e.getResponse().getStatus() == 422) { /* prompt user for name */ }\n}","preventionTips":["Annotate DTO field with @NotNull to get standard 400 responses","Validate payload in client before PUT","Avoid PUT with an empty/partial body — use PATCH semantics","Include name in all serialized update payloads (not NON_NULL-inclusive models)"],"tags":["rest","validation","http-422","bean-validation"],"backgroundTag":"missing-required-request-field","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}