{"record":{"id":"aba0e5443f5d2058","repo":"flowable/flowable-engine","slug":"the-source-and-the-target-tenant-ids-must-be-diffe","errorCode":null,"errorMessage":"The source and the target tenant ids must be different.","messagePattern":"The source and the target tenant ids must be different\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/tenant/ChangeTenantIdBuilderImpl.java","lineNumber":40,"sourceCode":"public class ChangeTenantIdBuilderImpl implements ChangeTenantIdBuilder {\n\n    protected final String sourceTenantId;\n    protected final String targetTenantId;\n    protected final ChangeTenantIdManager changeTenantIdManager;\n\n    protected String definitionTenantId;\n\n    public ChangeTenantIdBuilderImpl(String sourceTenantId, String targetTenantId, ChangeTenantIdManager changeTenantIdManager) {\n        if (sourceTenantId == null) {\n            throw new FlowableIllegalArgumentException(\"The source tenant id must not be null.\");\n        }\n        if (targetTenantId == null) {\n            throw new FlowableIllegalArgumentException(\"The target tenant id must not be null.\");\n        }\n        this.sourceTenantId = sourceTenantId;\n        this.targetTenantId = targetTenantId;\n        if (sourceTenantId.equals(targetTenantId)) {\n            throw new FlowableIllegalArgumentException(\"The source and the target tenant ids must be different.\");\n        }\n        this.changeTenantIdManager = changeTenantIdManager;\n    }\n\n    @Override\n    public ChangeTenantIdBuilder definitionTenantId(String definitionTenantId) {\n        if (definitionTenantId == null) {\n            throw new FlowableIllegalArgumentException(\"definitionTenantId must not be null\");\n        }\n        this.definitionTenantId = definitionTenantId;\n        return this;\n    }\n\n    @Override\n    public ChangeTenantIdResult simulate() {\n        return changeTenantIdManager.simulate(this);\n    }\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/tenant/ChangeTenantIdBuilderImpl.java#L22-L58","documentation":"Flowable throws FlowableIllegalArgumentException when the source and target tenant ids passed to ChangeTenantIdBuilderImpl are equal. Moving data from a tenant to itself is a no-op or would corrupt the migration logic, so it is rejected upfront.","triggerScenarios":"Calling changeTenantId(\"tenantA\", \"tenantA\"), or passing variables that happen to hold the same tenant id on both sides of the call.","commonSituations":"Target tenant id accidentally defaulted to the source tenant id; programmatic tenant selection where the same tenant is resolved twice; test code reusing one tenant constant.","solutions":["Verify the caller passes a genuinely different target tenant id","Add an application-level check that source != target before invoking the builder","Log both ids at the call site to diagnose why they are identical"],"exampleFix":"// before\nmanagementService.changeTenantId(tenantId, tenantId);\n// after\nif (!tenantId.equals(newTenantId)) {\n    managementService.changeTenantId(tenantId, newTenantId);\n}","handlingStrategy":"validation","validationCode":"if (sourceTenantId.equals(targetTenantId)) {\n    throw new IllegalArgumentException(\"target must differ from source tenant\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    managementService.changeTenantId(sourceTenantId, targetTenantId);\n} catch (FlowableIllegalArgumentException e) {\n    logger.warn(\"Source and target tenant must differ: {} -> {}\", sourceTenantId, targetTenantId);\n}","preventionTips":["Check source != target before invoking the builder","Avoid defaulting target tenant to the source value in config code","Cover tenant migration in unit tests with distinct tenants"],"tags":["flowable","tenant","argument-validation","invalid-state"],"backgroundTag":"invalid-argument-value","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"}