{"record":{"id":"6b2e36a483ac6421","repo":"flowable/flowable-engine","slug":"must-specify-a-case-instance-id-to-migrate","errorCode":null,"errorMessage":"Must specify a case instance id to migrate","messagePattern":"Must specify a case instance id to migrate","errorType":"validation","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CaseInstanceMigrationCmd.java","lineNumber":41,"sourceCode":"/**\n * @author Valentin Zickner\n */\npublic class CaseInstanceMigrationCmd implements Command<Void> {\n    \n    protected CmmnEngineConfiguration cmmnEngineConfiguration;\n\n    protected String caseInstanceId;\n    protected String caseDefinitionId;\n    protected String caseDefinitionKey;\n    protected int caseDefinitionVersion;\n    protected String caseDefinitionTenantId;\n    protected CaseInstanceMigrationDocument caseInstanceMigrationDocument;\n\n    public CaseInstanceMigrationCmd(String caseInstanceId, CaseInstanceMigrationDocument caseInstanceMigrationDocument,\n            CmmnEngineConfiguration cmmnEngineConfiguration) {\n        \n        if (caseInstanceId == null) {\n            throw new FlowableException(\"Must specify a case instance id to migrate\");\n        }\n        if (caseInstanceMigrationDocument == null) {\n            throw new FlowableException(\"Must specify a case instance migration document to migrate\");\n        }\n        \n        this.caseInstanceId = caseInstanceId;\n        this.caseInstanceMigrationDocument = caseInstanceMigrationDocument;\n        this.cmmnEngineConfiguration = cmmnEngineConfiguration;\n    }\n\n    public CaseInstanceMigrationCmd(CaseInstanceMigrationDocument caseInstanceMigrationDocument, String caseDefinitionId,\n            CmmnEngineConfiguration cmmnEngineConfiguration) {\n        \n        if (caseDefinitionId == null) {\n            throw new FlowableException(\"Must specify a case definition id to migrate\");\n        }\n        if (caseInstanceMigrationDocument == null) {\n            throw new FlowableException(\"Must specify a case instance migration document to migrate\");","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CaseInstanceMigrationCmd.java#L23-L59","documentation":"Constructor guard on the case instance migration command: the caseInstanceId argument is null, so the migration document cannot be tied to a case instance and the command is rejected before execution.","triggerScenarios":"Constructing new CaseInstanceMigrationCmd(caseInstanceId, document, config) with caseInstanceId == null, e.g. when the id came from a request parameter that was absent or a lookup that returned nothing.","commonSituations":"REST payload missing the caseInstanceId field; variable initialized from an empty optional; wrong variable passed due to parameter ordering (id, document, config).","solutions":["Ensure the case instance id is resolved (e.g. from CaseInstanceQuery) and non-null before constructing the command","Validate at the API/controller layer that the id path/body parameter is present","Check parameter order in the constructor: id first, then document"],"exampleFix":"// before\nnew CaseInstanceMigrationCmd(caseInstanceId, doc, config); // caseInstanceId == null\n// after\nif (caseInstanceId == null || caseInstanceId.isEmpty()) {\n    throw new IllegalArgumentException(\"caseInstanceId is required\");\n}\nnew CaseInstanceMigrationCmd(caseInstanceId, doc, config);","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null || caseInstanceId.isEmpty()) {\n    throw new IllegalArgumentException(\"caseInstanceId is required for single-instance migration\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return new CaseInstanceMigrationCmd(caseInstanceId, document, config);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"case instance id\")) {\n        // resolve id from CaseInstanceQuery or reject the request upstream\n    }\n    throw e;\n}","preventionTips":["Validate REST input for caseInstanceId before invoking the engine","Resolve ids via CaseInstanceQuery rather than trusting client-supplied values","Remember constructor order: (caseInstanceId, document, configuration)"],"tags":["cmmn","migration","null-argument","constructor"],"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"}