{"record":{"id":"502c6af913972122","repo":"flowable/flowable-engine","slug":"type-has-to-be-provided","errorCode":null,"errorMessage":"type has to be provided","messagePattern":"type has to be provided","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-batch-service/src/main/java/org/flowable/batch/service/BatchPartBuilderImpl.java","lineNumber":114,"sourceCode":"    }\n\n    @Override\n    public BatchPartBuilder scopeType(String scopeType) {\n        if (scopeType == null) {\n            throw new FlowableIllegalArgumentException(\"scopeType is null\");\n        }\n        this.scopeType = scopeType;\n        return this;\n    }\n\n    @Override\n    public BatchPart create() {\n        if (batch == null) {\n            throw new FlowableIllegalArgumentException(\"batch has to be provided\");\n        }\n\n        if (type == null) {\n            throw new FlowableIllegalArgumentException(\"type has to be provided\");\n        }\n        if (commandExecutor != null) {\n            return commandExecutor.execute(commandContext -> createSafe());\n        } else {\n            return createSafe();\n        }\n    }\n\n    protected BatchPart createSafe() {\n        BatchPartEntityManager partEntityManager = batchServiceConfiguration.getBatchPartEntityManager();\n        BatchPartEntity batchPart = partEntityManager.create();\n        batchPart.setBatchId(batch.getId());\n        batchPart.setBatchType(batch.getBatchType());\n        batchPart.setBatchSearchKey(batch.getBatchSearchKey());\n        batchPart.setBatchSearchKey2(batch.getBatchSearchKey2());\n        if (batch.getTenantId() != null) {\n            batchPart.setTenantId(batch.getTenantId());\n        }","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-batch-service/src/main/java/org/flowable/batch/service/BatchPartBuilderImpl.java#L96-L132","documentation":"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.","triggerScenarios":"Calling BatchPartBuilder.create() without calling type(String) on the builder, or calling type(null).","commonSituations":"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.","solutions":["Call type(\"<your-registered-batch-part-type>\") on the builder before create().","Ensure the type string matches one registered in BatchServiceConfiguration (batchTypeHandlers / batchTypes), else validation or routing fails later.","If the type comes from a variable, null-check it before building.","Check that refactoring did not drop the type(...) line in the builder chain."],"exampleFix":"// before\nBatchPart part = batchService.createBatchPartBuilder()\n    .batch(batch)\n    .create();\n// after\nBatchPart part = batchService.createBatchPartBuilder()\n    .batch(batch)\n    .type(\"search\")\n    .create();","handlingStrategy":"validation","validationCode":"if (partType == null || partType.isEmpty()) {\n    throw new IllegalStateException(\"Batch part type must be set before create()\");\n}\nBatchPart part = batchService.createBatchPartBuilder()\n    .batch(batch)\n    .type(partType)\n    .create();","typeGuard":"boolean isValidBatchPartType(String t) {\n    return t != null && !t.trim().isEmpty();\n}","tryCatchPattern":"try {\n    BatchPart part = builder.create();\n} catch (org.flowable.common.engine.api.FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"type has to be provided\")) {\n        throw new IllegalStateException(\"BatchPartBuilder.type(...) was not called before create()\", e);\n    }\n    throw e;\n}","preventionTips":["Define batch part types as constants/enums and require one in your helper method signature.","Validate type values against the registered batch types in BatchServiceConfiguration.","Keep the type(...) call adjacent to batch(...) in builder chains so it cannot be dropped."],"tags":["flowable","batch","builder","null-check"],"backgroundTag":"missing-required-argument","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"}