{"record":{"id":"9451d6d9940792d8","repo":"flowable/flowable-engine","slug":"no-batch-part-found-for-id-batchpartid","errorCode":null,"errorMessage":"No batch part found for id ${batchPartId}","messagePattern":"No batch part found for id (.+?)","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetBatchPartCmd.java","lineNumber":35,"sourceCode":"import org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;\nimport org.flowable.engine.impl.util.CommandContextUtil;\n\npublic class GetBatchPartCmd implements Command<BatchPart> {\n    \n    protected String batchPartId;\n    \n    public GetBatchPartCmd(String batchPartId) {\n        this.batchPartId = batchPartId;\n    }\n    \n    @Override\n    public BatchPart execute(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        BatchPart batchPart = processEngineConfiguration.getBatchServiceConfiguration().getBatchService().getBatchPart(batchPartId);\n        if (batchPart == null) {\n            throw new FlowableObjectNotFoundException(\"No batch part found for id \" + batchPartId);\n        }\n        \n        return batchPart;\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":41,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetBatchPartCmd.java#L17-L41","documentation":"GetBatchPartCmd looks up a batch part by id via the batch service. When the batch service returns null (no batch part with that id exists), the command throws FlowableObjectNotFoundException with the id embedded in the message. This means the batch part id is invalid, was mistyped, or the batch part has already been completed and removed.","triggerScenarios":"Calling managementService.getBatchPart(batchPartId) (or any API executing GetBatchPartCmd) with an id that does not correspond to a persistent batch part; the id is a batch id rather than a batch-part id; the batch part was deleted after completion.","commonSituations":"Polling a batch migration/rotation/instance-change part after it finished and was cleaned up; copying an id from the wrong table/management endpoint; using a process-instance id instead of the batch part id.","solutions":["Verify the batch part id via managementService.createBatchPartQuery().list() and use an id from the result","If querying a batch as a whole, use getBatch(batchId) or BatchQuery instead of the batch-part API","Check application code that retains the id — refresh it before each lookup instead of caching stale ids","Guard against completed batches by checking batch part status before querying after completion"],"exampleFix":"// before\nBatchPart part = managementService.getBatchPart(someBatchId); // wrong id / wrong API\n// after\nBatchPart part = managementService.createBatchPartQuery().batchId(someBatchId).singleResult();\nif (part != null) { /* use part */ }","handlingStrategy":"try-catch","validationCode":"BatchPart p = managementService.createBatchPartQuery().batchPartId(batchPartId).singleResult();\nif (p == null) throw new IllegalStateException(\"Unknown batch part \" + batchPartId);","typeGuard":null,"tryCatchPattern":"try {\n    BatchPart part = managementService.getBatchPart(batchPartId);\n} catch (FlowableObjectNotFoundException e) {\n    // treat as purged/unknown batch part\n}","preventionTips":["Resolve ids from createBatchPartQuery() rather than user input","Do not cache batch part ids beyond the batch lifecycle","Distinguish batch ids from batch-part ids in code and logs"],"tags":["flowable","batch","not-found"],"backgroundTag":"record-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}