flowable/flowable-engine · error · FlowableObjectNotFoundException

No batch part found for id ${batchPartId}

Error message

No batch part found for id ${batchPartId}

What it means

GetBatchPartDocumentCmd fetches a batch part by id and returns its result document JSON for the current engine config key. If no batch part exists for the id, it throws FlowableObjectNotFoundException. A valid batch part can also yield a null/empty result if the document is not yet available, but this specific error fires only when the part itself is missing.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetBatchPartDocumentCmd.java:35

import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil;

public class GetBatchPartDocumentCmd implements Command<String> {
    
    protected String batchPartId;
    
    public GetBatchPartDocumentCmd(String batchPartId) {
        this.batchPartId = batchPartId;
    }
    
    @Override
    public String execute(CommandContext commandContext) {
        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
        BatchPart batchPart = processEngineConfiguration.getBatchServiceConfiguration().getBatchService().getBatchPart(batchPartId);
        if (batchPart == null) {
            throw new FlowableObjectNotFoundException("No batch part found for id " + batchPartId);
        }
        
        return batchPart.getResultDocumentJson(processEngineConfiguration.getEngineCfgKey());
    }
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Look up valid ids with managementService.createBatchPartQuery() before fetching the document
  2. Ensure the batch part exists and has completed before reading its result document
  3. Verify you are passing a batch-part id, not a batch id
  4. Handle FlowableObjectNotFoundException to treat missing documents as 'not finished/purged'

Example fix

// before
String doc = managementService.getBatchPartDocument(userProvidedId);
// after
BatchPart part = managementService.getBatchPart(userProvidedId);
String doc = part != null ? managementService.getBatchPartDocument(userProvidedId) : null;
Defensive patterns

Strategy: try-catch

Validate before calling

if (managementService.createBatchPartQuery().batchPartId(batchPartId).count() == 0) return null;

Try / catch

try {
    String json = managementService.getBatchPartDocument(batchPartId);
} catch (FlowableObjectNotFoundException e) {
    String json = null; // document/part unavailable
}

Prevention

When it happens

Trigger: Calling managementService.getBatchPartDocument(batchPartId) with an unknown, mistyped, or already-deleted batch part id; passing a batch id instead of a batch-part id.

Common situations: Retrieving a result document for a finished batch that has been purged; constructing the id from a wrong source; calling before the batch part was persisted.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/2f77d441d2c90006. Report an issue: GitHub.