flowable/flowable-engine · error · FlowableIllegalArgumentException

type has to be provided

Error message

type has to be provided

What it means

BatchPartBuilderImpl.create() requires a batch part type (BatchPartBuilder.type(String)) which classifies the part within the batch (e.g. a search/batch-part type registered in BatchServiceConfiguration). When type was never set, Flowable throws FlowableIllegalArgumentException before persisting. This prevents unclassifiable batch parts that the batch type handlers could not route.

Source

Thrown at modules/flowable-batch-service/src/main/java/org/flowable/batch/service/BatchPartBuilderImpl.java:114

    }

    @Override
    public BatchPartBuilder scopeType(String scopeType) {
        if (scopeType == null) {
            throw new FlowableIllegalArgumentException("scopeType is null");
        }
        this.scopeType = scopeType;
        return this;
    }

    @Override
    public BatchPart create() {
        if (batch == null) {
            throw new FlowableIllegalArgumentException("batch has to be provided");
        }

        if (type == null) {
            throw new FlowableIllegalArgumentException("type has to be provided");
        }
        if (commandExecutor != null) {
            return commandExecutor.execute(commandContext -> createSafe());
        } else {
            return createSafe();
        }
    }

    protected BatchPart createSafe() {
        BatchPartEntityManager partEntityManager = batchServiceConfiguration.getBatchPartEntityManager();
        BatchPartEntity batchPart = partEntityManager.create();
        batchPart.setBatchId(batch.getId());
        batchPart.setBatchType(batch.getBatchType());
        batchPart.setBatchSearchKey(batch.getBatchSearchKey());
        batchPart.setBatchSearchKey2(batch.getBatchSearchKey2());
        if (batch.getTenantId() != null) {
            batchPart.setTenantId(batch.getTenantId());
        }

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Call type("<your-registered-batch-part-type>") on the builder before create().
  2. Ensure the type string matches one registered in BatchServiceConfiguration (batchTypeHandlers / batchTypes), else validation or routing fails later.
  3. If the type comes from a variable, null-check it before building.
  4. Check that refactoring did not drop the type(...) line in the builder chain.

Example fix

// before
BatchPart part = batchService.createBatchPartBuilder()
    .batch(batch)
    .create();
// after
BatchPart part = batchService.createBatchPartBuilder()
    .batch(batch)
    .type("search")
    .create();
Defensive patterns

Strategy: validation

Validate before calling

if (partType == null || partType.isEmpty()) {
    throw new IllegalStateException("Batch part type must be set before create()");
}
BatchPart part = batchService.createBatchPartBuilder()
    .batch(batch)
    .type(partType)
    .create();

Type guard

boolean isValidBatchPartType(String t) {
    return t != null && !t.trim().isEmpty();
}

Try / catch

try {
    BatchPart part = builder.create();
} catch (org.flowable.common.engine.api.FlowableIllegalArgumentException e) {
    if (e.getMessage().contains("type has to be provided")) {
        throw new IllegalStateException("BatchPartBuilder.type(...) was not called before create()", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling BatchPartBuilder.create() without calling type(String) on the builder, or calling type(null).

Common situations: Dynamic part creation where the type comes from config/lookup and was null; missing handler registration for a custom batch type so the caller skipped setting it; refactoring that renamed the type constant.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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