{"record":{"id":"3e929fb1354f16f5","repo":"flowable/flowable-engine","slug":"no-batch-found-for-id-batchid","errorCode":null,"errorMessage":"No batch found for id ${batchId}","messagePattern":"No batch found for id (.+?)","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetBatchDocumentCmd.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 GetBatchDocumentCmd implements Command<String> {\n    \n    protected String batchId;\n    \n    public GetBatchDocumentCmd(String batchId) {\n        this.batchId = batchId;\n    }\n    \n    @Override\n    public String execute(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        Batch batch = processEngineConfiguration.getBatchServiceConfiguration().getBatchService().getBatch(batchId);\n        if (batch == null) {\n            throw new FlowableObjectNotFoundException(\"No batch found for id \" + batchId);\n        }\n        \n        return batch.getBatchDocumentJson(processEngineConfiguration.getEngineCfgKey());\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/GetBatchDocumentCmd.java#L17-L41","documentation":"GetBatchDocumentCmd fetches a batch via the batch service; when getBatch(batchId) returns null it throws FlowableObjectNotFoundException. It returns the batch's document JSON for this engine configuration key.","triggerScenarios":"Querying a batch id that does not exist, belongs to another engine config key, or whose batch rows were purged by cleanup jobs.","commonSituations":"Monitoring dashboards holding batch ids after batch part cleanup ran; typo in batch id; pointing at a database where the batch table was truncated.","solutions":["Check the batch exists first via the batch service query before fetching its document","Verify batch cleanup/rotation jobs didn't delete the batch","Confirm the batchId string is complete and from the same engine configuration"],"exampleFix":"// before\nString doc = managementService.executeCommand(new GetBatchDocumentCmd(batchId));\n// after\nBatch batch = batchService.createBatchQuery().batchId(batchId).singleResult();\nString doc = batch != null\n    ? managementService.executeCommand(new GetBatchDocumentCmd(batchId)) : null;","handlingStrategy":"try-catch","validationCode":"Batch batch = batchService.createBatchQuery().batchId(batchId).singleResult();\nif (batch == null) throw new IllegalArgumentException(\"unknown batchId: \" + batchId);","typeGuard":null,"tryCatchPattern":"try { ... } catch (FlowableObjectNotFoundException e) { if (e.getMessage().startsWith(\"No batch found\")) { /* treat as expired batch; refresh from batch query */ } else throw e; }","preventionTips":["Treat batch ids as ephemeral; re-query before document fetch","Account for batch cleanup jobs removing old batches","Validate batchId source (same engine/config key) before use"],"tags":["flowable","batch","not-found"],"backgroundTag":"entity-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"}