{"record":{"id":"aeb2a87013f72701","repo":"flowable/flowable-engine","slug":"the-source-tenant-id-must-not-be-null","errorCode":null,"errorMessage":"The source tenant id must not be null.","messagePattern":"The source tenant id must not be null\\.","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":32,"sourceCode":"\nimport org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.api.tenant.ChangeTenantIdBuilder;\nimport org.flowable.common.engine.api.tenant.ChangeTenantIdResult;\n\n/**\n * @author Filip Hrisafov\n */\npublic 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;","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/tenant/ChangeTenantIdBuilderImpl.java#L14-L50","documentation":"ChangeTenantIdBuilderImpl's constructor validates its arguments: a null sourceTenantId or targetTenantId throws FlowableIllegalArgumentException('The source tenant id must not be null.'). Tenant ids are used as query keys when moving definitions between tenants, so nulls are rejected immediately.","triggerScenarios":"Calling managementService.createChangeTenantIdBuilder(null, target) (or passing a null that came from an unset variable/config) — first hit is the source-id check at line 32.","commonSituations":"Tenant ids read from a database row or request parameter that is null; refactoring where constants were removed; code paths constructing the builder from nullable user input.","solutions":["Pass non-null string tenant ids, e.g. createChangeTenantIdBuilder(\"sourceTenant\", \"targetTenant\").","Validate tenant ids at the API/UI layer before invoking the builder.","Replace null with the actual tenant key or fail early with a domain-specific message."],"exampleFix":"// before\nString from = request.getParameter(\"sourceTenant\"); // may be null\nmanagementService.createChangeTenantIdBuilder(from, to).execute();\n\n// after\nString from = request.getParameter(\"sourceTenant\");\nif (from == null || to == null) throw new BadRequestException(\"sourceTenant and targetTenant are required\");\nmanagementService.createChangeTenantIdBuilder(from, to).execute();","handlingStrategy":"validation","validationCode":"if (sourceTenantId == null || targetTenantId == null) {\n    throw new IllegalArgumentException(\"sourceTenantId and targetTenantId must be non-null\");\n}","typeGuard":"boolean validTenants(String src, String tgt) { return src != null && tgt != null; }","tryCatchPattern":"try {\n    managementService.createChangeTenantIdBuilder(src, tgt).execute();\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"Tenant ids must be provided: \" + e.getMessage(), e);\n}","preventionTips":["Validate tenant ids from request parameters/DB rows before calling the builder.","Use Optional.ofNullable(sourceTenantId).orElseThrow(...) at the call site.","Never pass values straight from nullable inputs into tenant APIs."],"tags":["tenant","null-argument","validation"],"backgroundTag":"null-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"}