quarkusio/quarkus · error · WebApplicationException
Fruit with id of " + id + " does not exist.
Error message
Fruit with id of " + id + " does not exist.
What it means
FruitResource.findById (datasource variant) throws this WebApplicationException (HTTP 404) when entityManager.find(Fruit.class, id) returns null, meaning no Fruit with that id exists in the database visible to the current tenant.
Source
Thrown at integration-tests/hibernate-orm-tenancy/datasource/src/main/java/io/quarkus/it/hibernate/multitenancy/fruit/FruitResource.java:70
.getResultList().toArray(new Fruit[0]);
}
@GET
@Path("fruits/{id}")
public Fruit getSingleDefault(@PathParam("id") int id) {
return findById(id);
}
@GET
@Path("{tenant}/fruits/{id}")
public Fruit getSingleTenant(@PathParam("id") int id) {
return findById(id);
}
private Fruit findById(int id) {
Fruit entity = entityManager.find(Fruit.class, id);
if (entity == null) {
throw new WebApplicationException("Fruit with id of " + id + " does not exist.", 404);
}
return entity;
}
@POST
@Transactional
@Path("fruits")
public Response createDefault(@NotNull Fruit fruit) {
return create(fruit);
}
@POST
@Transactional
@Path("{tenant}/fruits")
public Response createTenant(@NotNull Fruit fruit) {
return create(fruit);
}
View on GitHub (pinned to e1c734241f)
Solutions
- Confirm the id via the list endpoint GET /fruits before fetching by id.
- Ensure the tenant identifier matches the tenant owning the row.
- Handle 404 in the client as 'not found' and do not retry.
- Create the entity if it should exist.
Example fix
// before GET /fruits/999 // 404 // after GET /fruits/1 // use an id that exists for the current tenant
Defensive patterns
Strategy: try-catch
Validate before calling
List<Integer> ids = target("/fruits").request().get(new GenericType<List<Fruit>>(){})
.stream().map(Fruit::getId).collect(Collectors.toList());
if (!ids.contains(id)) { throw new IllegalStateException("Fruit " + id + " not found"); } Try / catch
try {
return target("/fruits/" + id).request().get(Fruit.class);
} catch (WebApplicationException e) {
if (e.getResponse().getStatus() == 404) { return Optional.empty(); }
throw e;
} Prevention
- Verify tenant header before cross-tenant lookups
- Use Optional/empty handling for possibly-missing entities
- Avoid hardcoding ids in tests; query them first
- Handle auto-increment gaps; never assume consecutive ids
When it happens
Trigger: GET /fruits/{id} with an id that has no row, or a row that belongs to a different tenant than the one selected by the request's tenant identifier.
Common situations: Wrong tenant header/datasource so the row is in another schema, entity deleted concurrently, stale bookmarked URL, or off-by-one/auto-increment gap ids.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Fruit with id of {id} does not exist.
- Fruit with id of ${id} does not exist.
- Id was invalidly set on request.
- Fruit Name was not set on request.
- Id was invalidly set on request.
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/31be861e00e6e326.
Report an issue: GitHub.