{"record":{"id":"77e14c113f0377e9","repo":"flowable/flowable-engine","slug":"scopeid-is-null","errorCode":null,"errorMessage":"scopeId is null","messagePattern":"scopeId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-batch-service/src/main/java/org/flowable/batch/service/BatchPartBuilderImpl.java","lineNumber":83,"sourceCode":"    @Override\n    public BatchPartBuilder searchKey2(String searchKey2) {\n        this.searchKey2 = searchKey2;\n        return this;\n    }\n\n    @Override\n    public BatchPartBuilder status(String status) {\n        if (status == null) {\n            throw new FlowableIllegalArgumentException(\"status is null\");\n        }\n        this.status = status;\n        return this;\n    }\n\n    @Override\n    public BatchPartBuilder scopeId(String scopeId) {\n        if (scopeId == null) {\n            throw new FlowableIllegalArgumentException(\"scopeId is null\");\n        }\n        this.scopeId = scopeId;\n        return this;\n    }\n\n    @Override\n    public BatchPartBuilder subScopeId(String subScopeId) {\n        if (subScopeId == null) {\n            throw new FlowableIllegalArgumentException(\"subScopeId is null\");\n        }\n        this.subScopeId = subScopeId;\n        return this;\n    }\n\n    @Override\n    public BatchPartBuilder scopeType(String scopeType) {\n        if (scopeType == null) {\n            throw new FlowableIllegalArgumentException(\"scopeType is null\");","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-batch-service/src/main/java/org/flowable/batch/service/BatchPartBuilderImpl.java#L65-L101","documentation":"BatchPartBuilderImpl.scopeId(String) throws FlowableIllegalArgumentException when scopeId is null. The scope id links the batch part to the scope (e.g. process/case/task instance) it operates on and is a required field.","triggerScenarios":"Calling .scopeId(null) while building a batch part, e.g. when the execution/entity id variable is null because the target instance was not resolved.","commonSituations":"Bulk operations iterating over instances where some ids failed to resolve; passing execution.getId() from a detached or already-ended execution.","solutions":["Resolve and pass a valid scope id (process instance / case / task id) before building the batch part","Skip building the part when the target instance id cannot be resolved, and log/skip instead","Check upstream lookups (runtimeService.create...Query) that may have returned null"],"exampleFix":"// before\nbuilder.scopeId(possiblyNullId);\n// after\nif (possiblyNullId == null) {\n    throw new IllegalStateException(\"Scope id must be resolved before creating a batch part\");\n}\nbuilder.scopeId(possiblyNullId);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(scopeId, \"scopeId must be resolved before creating a batch part\");\nbuilder.scopeId(scopeId);","typeGuard":"boolean hasScope = scopeId instanceof String s && !s.isEmpty();","tryCatchPattern":"try {\n    builder.scopeId(scopeId);\n} catch (FlowableIllegalArgumentException e) {\n    throw new IllegalStateException(\"Cannot create batch part: target scope id not resolved\", e);\n}","preventionTips":["Verify the target instance exists before scheduling batch work","Log and skip unresolved instances in bulk operations instead of passing null ids","Propagate ids explicitly rather than re-querying possibly-ended executions"],"tags":["null-argument","batch","flowable"],"backgroundTag":"null-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"}