{"record":{"id":"e91b2e464b8234a5","repo":"quarkusio/quarkus","slug":"fruit-with-id-of-id-does-not-exist-e91b2e","errorCode":null,"errorMessage":"Fruit with id of {id} does not exist.","messagePattern":"Fruit with id of (.+?) does not exist\\.","errorType":"http","errorClass":"WebApplicationException","httpStatus":404,"severity":"error","filePath":"integration-tests/hibernate-orm-tenancy/schema-mariadb/src/main/java/io/quarkus/it/hibernate/multitenancy/fruit/FruitResource.java","lineNumber":70,"sourceCode":"                .getResultList().toArray(new Fruit[0]);\n    }\n\n    @GET\n    @Path(\"fruits/{id}\")\n    public Fruit getSingleDefault(@PathParam(\"id\") int id) {\n        return findById(id);\n    }\n\n    @GET\n    @Path(\"{tenant}/fruits/{id}\")\n    public Fruit getSingleTenant(@PathParam(\"id\") int id) {\n        return findById(id);\n    }\n\n    private Fruit findById(int id) {\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        return entity;\n    }\n\n    @POST\n    @Transactional\n    @Path(\"fruits\")\n    public Response createDefault(@NotNull Fruit fruit) {\n        return create(fruit);\n    }\n\n    @POST\n    @Transactional\n    @Path(\"{tenant}/fruits\")\n    public Response createTenant(@NotNull Fruit fruit) {\n        return create(fruit);\n    }\n","sourceCodeStart":52,"sourceCodeEnd":88,"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#L52-L88","documentation":"Thrown by the private findById helper of the schema-mariadb FruitResource when entityManager.find(Fruit.class, id) returns null — no Fruit with the given id exists in the tenant being accessed. The exception is a JAX-RS WebApplicationException carrying HTTP 404, so the client receives Not Found. The @Transactional lookup is aborted and any pending changes roll back.","triggerScenarios":"Calling GET /fruits/{id} (default or tenant variant) in the schema-mariadb application with an id that has no row in the active tenant schema.","commonSituations":"Hard-coded ids from another environment/database; request routed to the wrong tenant schema via tenant header; fruit deleted earlier in the test lifecycle; MariaDB container not seeded with expected test data.","solutions":["Confirm the id exists with a GET against the same tenant before use","Verify the tenant identifier resolves to the schema containing the data","Seed the MariaDB schema with the expected Fruit rows before the test/requests","Create the fruit via POST and use the returned entity id"],"exampleFix":"// before\nFruit f = given().header(\"tenantId\", \"tenant-fruit\").get(\"/fruits/7\").as(Fruit.class); // 404 if 7 absent\n// after\nResponse r = given().header(\"tenantId\", \"tenant-fruit\").get(\"/fruits/7\");\nif (r.getStatusCode() == 404) { /* create or pick a valid id */ }","handlingStrategy":"try-catch","validationCode":"Response check = given().header(\"tenantId\", tenant).get(\"/fruits/\" + id);\nAssume.assumeFalse(check.getStatusCode() == 404);","typeGuard":null,"tryCatchPattern":"Response r = given().header(\"tenantId\", tenant).get(\"/fruits/\" + id);\nif (r.getStatusCode() == 404) {\n    // handle not-found: seed data or pick a valid id\n} else {\n    Fruit fruit = r.as(Fruit.class);\n}","preventionTips":["Seed MariaDB test data per tenant before assertions","Never reuse ids across environments or tenants","Assert status code before deserializing the body","Send the tenant header consistently (RestAssured filter helps)"],"tags":["rest","jaxrs","http-404","hibernate-orm","multitenancy","mariadb"],"backgroundTag":"rest-resource-not-found","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}