{"record":{"id":"a75619cac7210d8b","repo":"flowable/flowable-engine","slug":"must-specify-a-case-definition-tenant-id-to-migrat-a75619","errorCode":null,"errorMessage":"Must specify a case definition tenant id to migrate","messagePattern":"Must specify a case definition tenant 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":74,"sourceCode":"            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\");\n        }\n        \n        this.caseDefinitionId = caseDefinitionId;\n        this.caseInstanceMigrationDocument = caseInstanceMigrationDocument;\n        this.cmmnEngineConfiguration = cmmnEngineConfiguration;\n    }\n\n    public CaseInstanceMigrationCmd(String caseDefinitionKey, int caseDefinitionVersion, String caseDefinitionTenantId, \n            CaseInstanceMigrationDocument caseInstanceMigrationDocument, CmmnEngineConfiguration cmmnEngineConfiguration) {\n        \n        if (caseDefinitionKey == null) {\n            throw new FlowableException(\"Must specify a case definition id to migrate\");\n        }\n        if (caseDefinitionTenantId == null) {\n            throw new FlowableException(\"Must specify a case definition tenant 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.caseDefinitionKey = caseDefinitionKey;\n        this.caseDefinitionVersion = caseDefinitionVersion;\n        this.caseDefinitionTenantId = caseDefinitionTenantId;\n        this.caseInstanceMigrationDocument = caseInstanceMigrationDocument;\n        this.cmmnEngineConfiguration = cmmnEngineConfiguration;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        CaseInstanceMigrationManager migrationManager = cmmnEngineConfiguration.getCaseInstanceMigrationManager();\n\n        if (caseInstanceId != null) {\n            migrationManager.migrateCaseInstance(caseInstanceId, caseInstanceMigrationDocument, commandContext);","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CaseInstanceMigrationCmd.java#L56-L92","documentation":"Thrown by the key/version/tenant-based CaseInstanceMigrationCmd constructor when caseDefinitionTenantId is null. When targeting a case definition by key+version, the tenant id is required to resolve the deployed definition in a multi-tenant setup.","triggerScenarios":"Calling createCaseInstanceMigrationBuilder().migrateToCaseDefinition(caseDefinitionKey, version, null).","commonSituations":"Multi-tenant deployments where tenant resolution fails or the tenant context is not propagated; single-tenant apps incorrectly forced into the key/version/tenant variant instead of using migrateToCaseDefinition(id) or key+version without tenant.","solutions":["Pass the correct tenant id: migrateToCaseDefinition(key, version, tenantId).","If no tenant isolation is used, target the definition by id instead (migrateToCaseDefinition(caseDefinitionId)).","Verify the tenant id is obtained from the authenticated tenant context before building the migration."],"exampleFix":"// before\nbuilder.migrateToCaseDefinition(\"orderCase\", 2, null);\n// after\nbuilder.migrateToCaseDefinition(\"orderCase\", 2, tenantService.getCurrentTenantId());","handlingStrategy":"validation","validationCode":"if (tenantId == null || tenantId.isEmpty()) {\n    throw new IllegalArgumentException(\"tenant id required when targeting by key+version\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    builder.migrateToCaseDefinition(key, version, tenantId);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"Must specify a case definition tenant id\")) {\n        // fall back to tenant-less id-based targeting\n    }\n}","preventionTips":["Centralize tenant resolution (e.g. a TenantProvider) so the id is never ad-hoc null.","If your app is not multi-tenant, target definitions by id instead of key+version+tenant.","Test tenant propagation in async/scheduled migration jobs."],"tags":["cmmn","case-migration","tenant","null-argument"],"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-14T05:17:10.506Z"}