{"record":{"id":"3c61c1d0ab4b3781","repo":"flowable/flowable-engine","slug":"null-task-id","errorCode":null,"errorMessage":"Null task id","messagePattern":"Null task id","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskCmd.java","lineNumber":80,"sourceCode":"            Map<String, Object> transientVariables, Map<String, Object> transientVariablesLocal) {\n        \n        this(taskId, variables, transientVariables);\n        this.variablesLocal = variablesLocal;\n        this.transientVariablesLocal = transientVariablesLocal;\n    }\n    \n    public CompleteTaskCmd(String taskId, String userId, Map<String, Object> variables, Map<String, Object> variablesLocal,\n            Map<String, Object> transientVariables, Map<String, Object> transientVariablesLocal) {\n        \n        this(taskId, variables, variablesLocal, transientVariables, transientVariablesLocal);\n        this.userId = userId;\n    }\n    \n    @Override\n    public Void execute(CommandContext commandContext) {\n        \n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"Null task id\");\n        }\n        \n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        TaskEntity taskEntity = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);\n        if (taskEntity == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find task entity for id \" + taskId, TaskEntity.class);\n        }\n        \n        if (StringUtils.isNotEmpty(taskEntity.getProcessInstanceId())) {\n            throw new FlowableException(taskEntity + \" is created by the process engine and should be completed via the process engine API\");\n        }\n        \n        String planItemInstanceId = taskEntity.getSubScopeId();\n        PlanItemInstanceEntity planItemInstanceEntity = null;\n        if (planItemInstanceId != null) {\n            planItemInstanceEntity = cmmnEngineConfiguration.getPlanItemInstanceEntityManager().findById(planItemInstanceId);\n            if (planItemInstanceEntity == null) {\n                throw new FlowableException(\"Could not find plan item instance for \" + taskEntity);","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskCmd.java#L62-L98","documentation":"CompleteTaskCmd.execute() begins by validating that a task id was supplied; a null taskId causes FlowableIllegalArgumentException(\"Null task id\"). This is a fail-fast guard before any engine lookup happens.","triggerScenarios":"Calling cmmnTaskService.complete(null), or complete(variables) style overloads where the id variable resolved to null.","commonSituations":"Task id extracted from a request/DTO that omitted it; a prior query returned no result and its id field was null; constructor CompleteTaskCmd(null) from custom code.","solutions":["Pass a non-null task id to cmmnTaskService.complete(taskId).","Validate the id in the caller (e.g. @NotBlank on the DTO / early null check) before invoking the API.","If the id came from a query result, check the entity exists before reading its id."],"exampleFix":"// before\nString taskId = request.getTaskId(); // may be null\ncmmnTaskService.complete(taskId);\n\n// after\nif (request.getTaskId() == null || request.getTaskId().isBlank()) {\n    throw new IllegalArgumentException(\"taskId is required\");\n}\ncmmnTaskService.complete(request.getTaskId());","handlingStrategy":"validation","validationCode":"if (taskId == null || taskId.isBlank()) throw new IllegalArgumentException(\"taskId is required\");","typeGuard":null,"tryCatchPattern":"try { cmmnTaskService.complete(taskId); } catch (FlowableIllegalArgumentException e) { /* null id */ } catch (FlowableObjectNotFoundException e) { /* unknown id */ }","preventionTips":["Validate the task id at the boundary (REST/DTO validation) before calling the engine.","Never pass ids from unverified query results; null-check the entity first.","Make task id a required, non-null field in your service signatures."],"tags":["cmmn","task","null","validation","java"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}