{"record":{"id":"66eb9e575b4db73a","repo":"quarkusio/quarkus","slug":"fruit-name-was-not-set-on-request-66eb9e","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-orm-tenancy/datasource/src/main/java/io/quarkus/it/hibernate/multitenancy/fruit/FruitResource.java","lineNumber":114,"sourceCode":"    }\n\n    @PUT\n    @Path(\"fruits/{id}\")\n    @Transactional\n    public Fruit updateDefault(@PathParam(\"id\") int id, @NotNull Fruit fruit) {\n        return update(id, fruit);\n    }\n\n    @PUT\n    @Path(\"{tenant}/fruits/{id}\")\n    @Transactional\n    public Fruit updateTenant(@PathParam(\"id\") int id, @NotNull Fruit fruit) {\n        return update(id, fruit);\n    }\n\n    private 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(\"fruits/{id}\")\n    @Transactional\n    public Response deleteDefault(@PathParam(\"id\") int id) {\n        return delete(id);","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/hibernate-orm-tenancy/datasource/src/main/java/io/quarkus/it/hibernate/multitenancy/fruit/FruitResource.java#L96-L132","documentation":"WebApplicationException (422) from FruitResource.update: the PUT request body's Fruit object has a null name, which the endpoint's manual validation rejects. The input at fault is the 'name' field of the deserialized Fruit request body; bean validation on @NotNull Fruit alone did not cover it, so the guard fires.","triggerScenarios":"PUT /fruits/{id} with JSON body missing \"name\" or with \"name\": null.","commonSituations":"Partial updates sent to a full-replace PUT endpoint, unpopulated client DTO, or serialization dropping null/blank fields.","solutions":["Send the complete entity including name in the PUT body.","Validate on the client that name is non-null before the request.","Change the endpoint to PATCH semantics if partial updates are intended."],"exampleFix":"// before\n{\"id\": 1}\n// after\n{\"id\": 1, \"name\": \"Banana\"}","handlingStrategy":"validation","validationCode":"if (fruit == null || fruit.getName() == null || fruit.getName().isBlank()) {\n    throw new IllegalArgumentException(\"PUT body must include a non-blank name\");\n}","typeGuard":"boolean hasName(io.quarkus.it.hibernate.multitenancy.fruit.Fruit f) {\n    return f != null && f.getName() != null && !f.getName().isBlank();\n}","tryCatchPattern":"try {\n    return target(\"/fruits/\" + id).request().put(Entity.json(fruit), Fruit.class);\n} catch (WebApplicationException e) {\n    if (e.getResponse().getStatus() == 422) { /* fill name and retry once */ }\n    throw e;\n}","preventionTips":["Always send full representations on PUT","Client-side required-field validation","Distinguish PUT (full) from PATCH (partial)","Assert payloads in integration tests"],"tags":["rest","validation","jpa","http-422"],"backgroundTag":"missing-required-argument","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"}