{"record":{"id":"6d61326ef35c156f","repo":"flowable/flowable-engine","slug":"process-instance-id-is-required","errorCode":null,"errorMessage":"Process instance id is required","messagePattern":"Process instance id is required","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ChangeActivityStateCmd.java","lineNumber":42,"sourceCode":" * @author Tijs Rademakers\n */\npublic class ChangeActivityStateCmd implements Command<Void> {\n\n    protected ChangeActivityStateBuilderImpl changeActivityStateBuilder;\n\n    public ChangeActivityStateCmd(ChangeActivityStateBuilderImpl changeActivityStateBuilder) {\n        this.changeActivityStateBuilder = changeActivityStateBuilder;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (changeActivityStateBuilder.getMoveExecutionIdList().isEmpty() && changeActivityStateBuilder.getMoveActivityIdList().isEmpty()\n                && changeActivityStateBuilder.getEnableActivityIdList().isEmpty()) {\n            \n            throw new FlowableIllegalArgumentException(\"No move execution or activity ids or enable activity ids provided\");\n\n        } else if ((!changeActivityStateBuilder.getMoveActivityIdList().isEmpty() || !changeActivityStateBuilder.getEnableActivityIdList().isEmpty()) && changeActivityStateBuilder.getProcessInstanceId() == null) {\n            throw new FlowableIllegalArgumentException(\"Process instance id is required\");\n        }\n\n        DynamicStateManager dynamicStateManager = CommandContextUtil.getProcessEngineConfiguration(commandContext).getDynamicStateManager();\n        dynamicStateManager.moveExecutionState(changeActivityStateBuilder, commandContext);\n\n        return null;\n    }\n}\n","sourceCodeStart":24,"sourceCodeEnd":51,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ChangeActivityStateCmd.java#L24-L51","documentation":"When moving or enabling by activity id (rather than by execution id), ChangeActivityStateCmd needs the process instance id to locate the state to change. Flowable throws FlowableIllegalArgumentException if moveActivityIdList or enableActivityIdList is non-empty but processInstanceId was never set on the builder.","triggerScenarios":"runtimeService.createChangeActivityStateBuilder().moveActivityIdTo(\"a\",\"b\").changeState() without calling processInstanceId(...); same for enableActivity(...) without a process instance id.","commonSituations":"Using activity-id based movement but forgetting the builder's processInstanceId() call; copying execution-id based examples (which don't need the id) and switching to activity ids.","solutions":["Call .processInstanceId(processInstanceId) on the ChangeActivityStateBuilder before changeState().","Alternatively move by execution id (moveExecutionIdTo...) which does not require processInstanceId.","Pre-validate that processInstanceId is set whenever move/enable activity ids are used."],"exampleFix":"// before\nruntimeService.createChangeActivityStateBuilder()\n    .moveActivityIdTo(\"task1\", \"task2\").changeState();\n// after\nruntimeService.createChangeActivityStateBuilder()\n    .processInstanceId(processInstanceId)\n    .moveActivityIdTo(\"task1\", \"task2\").changeState();","handlingStrategy":"validation","validationCode":"if ((moveActivityIds.size() > 0 || enableActivityIds.size() > 0) && processInstanceId == null) {\n    throw new IllegalArgumentException(\"processInstanceId is required for activity-id based moves\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call .processInstanceId(...) when using moveActivityIdTo/enableActivity.","Prefer execution-id based moves only when you already hold execution ids.","Write a wrapper API that makes processInstanceId a mandatory parameter."],"tags":["flowable","process-instance","missing-argument","runtime-state"],"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-18T11:17:12.947Z"}