flowable/flowable-engine · error · FlowableObjectNotFoundException
No batch found for id ${batchId}
Error message
No batch found for id ${batchId} What it means
This Flowable REST endpoint (GET /management/batches/{batchId}/batch-parts) looks up a Batch by id via managementService.createBatchQuery().batchId(batchId). When the query returns null because no batch with that id exists, the controller throws FlowableObjectNotFoundException with a message embedding the requested batchId. It is the REST layer's way of turning an unknown batch id into a 404-style response.
Source
Thrown at modules/flowable-rest/src/main/java/org/flowable/rest/service/api/management/BatchPartCollectionResource.java:67
@Autowired(required=false)
protected BpmnRestApiInterceptor restApiInterceptor;
@ApiOperation(value = "List batch parts", tags = { "Batches" }, nickname = "listBatchesPart")
@ApiImplicitParams({
@ApiImplicitParam(name = "status", dataType = "string", value = "Only return batch parts for the given status", paramType = "query")
})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indicates the requested batch parts were returned."),
@ApiResponse(code = 400, message = "Indicates an illegal value has been used in a url query parameter. Status description contains additional details about the error.")
})
@GetMapping(value = "/management/batches/{batchId}/batch-parts", produces = "application/json")
public List<BatchPartResponse> getBatches(@PathVariable String batchId,
@ApiParam(hidden = true) @RequestParam Map<String, String> allRequestParams) {
Batch batch = managementService.createBatchQuery().batchId(batchId).singleResult();
if (batch == null) {
throw new FlowableObjectNotFoundException("No batch found for id " + batchId);
}
if (restApiInterceptor != null) {
restApiInterceptor.accessBatchPartInfoOfBatch(batch);
}
List<BatchPart> batchParts = null;
if (allRequestParams.containsKey("status")) {
batchParts = managementService.findBatchPartsByBatchIdAndStatus(batchId, allRequestParams.get("status"));
} else {
batchParts = managementService.findBatchPartsByBatchId(batchId);
}
return restResponseFactory.createBatchPartResponse(batchParts);
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the batchId exists: query ACT_RU_BATCH (or run managementService.createBatchQuery().list()) and use a real id.
- Use the batch id (not a batch-part id) in the URL path.
- Confirm the REST client points at the same database/tenant where the batch was created.
- If batches are purged automatically, re-check lifecycle: a finished batch may no longer be queryable, so handle the 404 in the client.
Example fix
// before
List<BatchPartResponse> parts = client.get("/management/batches/" + partId + "/batch-parts"); // partId used by mistake
// after
List<BatchPartResponse> parts = client.get("/management/batches/" + batch.getId() + "/batch-parts"); Defensive patterns
Strategy: validation
Validate before calling
Batch batch = managementService.createBatchQuery().batchId(batchId).singleResult();
if (batch == null) { throw new IllegalArgumentException("Unknown batch id: " + batchId); } Type guard
if (batchId == null || batchId.isBlank()) { /* reject before calling */ } Try / catch
try { parts = restClient.getBatchParts(batchId); }
catch (FlowableObjectNotFoundException e) { log.warn("Batch {} not found", batchId); return Collections.emptyList(); } Prevention
- Always resolve the batch id from a prior batch-query call instead of hardcoding.
- Check ACT_RU_BATCH for the id before invoking the REST endpoint.
- Don't confuse batch ids with batch-part ids.
- Account for automatic batch cleanup removing finished batches.
When it happens
Trigger: Calling GET /management/batches/{batchId}/batch-parts with a batchId that does not exist (typo, batch already completed and deleted, or id from a different database/tenant).
Common situations: Using a batch-part id instead of the batch id in the URL; referring to a batch whose history/row was purged by batch cleanup; pointing the REST client at a different Flowable database than where the batch was created.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Batch with id '${batchId}' does not have a batch document.
- Could not find a batch with id '${batchId}'.
- Could not find a case instance with id '${caseInstanceId}'.
- Historic task instance '' variable value for couldn't be fo
- Historic variable instance '' couldn't be found.
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/a11b88866afb84a8.
Report an issue: GitHub.