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
Thrown by the public findById endpoint of the Hibernate Search Elasticsearch tenancy FruitResource when entityManager.find(Fruit.class, id) finds no Fruit for the given id in the current tenant. It is a JAX-RS WebApplicationException mapped to HTTP 404. Unlike the schema-based sample, this is the public resource method itself, executed within @Transactional so the session/tenant context is active.
Source
Thrown at integration-tests/hibernate-search-orm-elasticsearch-tenancy/src/main/java/io/quarkus/it/hibernate/search/orm/elasticsearch/multitenancy/fruit/FruitResource.java:52
EntityManager entityManager;
@Inject
SearchSession searchSession;
@GET
@Path("/")
@Transactional
public Fruit[] getAll() {
return entityManager.createNamedQuery("Fruits.findAll", Fruit.class)
.getResultList().toArray(new Fruit[0]);
}
@GET
@Path("/{id}")
@Transactional
public 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
@Path("/")
@Transactional
public Response create(@NotNull Fruit fruit) {
if (fruit.getId() != null) {
throw new WebApplicationException("Id was invalidly set on request.", 422);
}
LOG.debugv("Create {0}", fruit.getName());
entityManager.persist(fruit);
return Response.ok(fruit).status(Response.Status.CREATED).build();
}
@PUT
@Path("/{id}")View on GitHub (pinned to e1c734241f)
Solutions
- Fetch with the same tenant header used at creation time
- Verify existence first via GET or the search endpoint, or catch the 404 client-side
- Seed the fruit for the tenant under test before requesting it
- Create the fruit with POST /fruits and use the returned id
Example fix
// before
given().header("tenantId", "tenant-b").get("/fruits/" + idCreatedForTenantA) // 404
// after
given().header("tenantId", "tenant-a").get("/fruits/" + idCreatedForTenantA) // 200 Defensive patterns
Strategy: try-catch
Validate before calling
if (given().header("tenantId", tenant).get("/fruits/" + id).getStatusCode() == 404) {
throw new SkipException("No fruit " + id + " for tenant " + tenant);
} Try / catch
try {
Fruit f = given().header("tenantId", tenant).get("/fruits/" + id).then()
.statusCode(200).extract().as(Fruit.class);
} catch (AssertionError notFound) {
// 404: handle missing entity for this tenant
} Prevention
- Pair create and read calls with the same tenant header
- Seed fruits per tenant before lookup-based tests
- Capture ids from creation responses rather than constants
- Remember entity lookups go through ORM with tenant filter, not the Elasticsearch index
When it happens
Trigger: GET /fruits/{id} on the hibernate-search-orm-elasticsearch-tenancy application with an id that does not exist in the active tenant, whether deleted, never created, or belonging to another tenant's index/schema.
Common situations: Id created under tenant A but fetched under tenant B (Search index and DB both tenant-filtered); Elasticsearch indexing lag is irrelevant here since the lookup uses the ORM, but missing DB seed data triggers it; stale ids across test lifecycle methods.
Related errors
- Fruit with id of {id} does not exist.
- Fruit with id of " + id + " does not exist.
- Extra steps left over
- Unsupported value type: %s
- Unable to fully read json value
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/76b7515a39b0649e.
Report an issue: GitHub.