{"record":{"id":"5afbdafcdb2f6fba","repo":"quarkusio/quarkus","slug":"fruit-name-was-not-set-on-request-5afbda","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":"warning","filePath":"integration-tests/hibernate-orm-tenancy/schema-mariadb/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/schema-mariadb/src/main/java/io/quarkus/it/hibernate/multitenancy/fruit/FruitResource.java#L96-L132","documentation":"Thrown by the update helper of the schema-mariadb FruitResource when the PUT request body has a null name. An update without a name is considered an invalid representation, so the resource responds with HTTP 422 (Unprocessable Entity) before touching the database, and the surrounding @Transactional work aborts.","triggerScenarios":"PUT /fruits/{id} with a JSON body missing the name field (\"{}\" or {\"id\":1}), or a Fruit deserialized where name was never set.","commonSituations":"Client sends a partial update payload assuming PATCH semantics on a PUT endpoint; serialization drops the name due to a DTO mapping bug; frontend form allows empty submit.","solutions":["Include the name field in the PUT request body","Client-side validate that name is non-null/non-blank before sending","For partial updates, implement PATCH semantics or fetch-modify-PUT the full entity","Return a clearer message via bean validation (@NotBlank on the entity) if desired"],"exampleFix":"// before\ngiven().body(\"{}\").put(\"/fruits/1\"); // 422 name missing\n// after\ngiven().contentType(ContentType.JSON).body(new Fruit(\"Apple\")).put(\"/fruits/1\"); // name present","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(fruit.getName(), \"name is required for PUT /fruits/{id}\");","typeGuard":"static boolean isUpdatable(Fruit f) {\n    return f != null && f.getName() != null && !f.getName().isBlank();\n}","tryCatchPattern":"try {\n    given().body(fruit).put(\"/fruits/\" + id);\n} catch (WebApplicationException e) {\n    if (e.getResponse().getStatus() == 422) { /* supply a name and retry */ }\n    else throw e;\n}","preventionTips":["Validate required fields (name) before sending PUT","Remember PUT requires full representation; use fetch-modify-PUT for partial changes","Make UI forms require the name field before submit","In tests, always construct Fruit with a non-null name"],"tags":["rest","jaxrs","http-422","validation","put"],"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"}