{"record":{"id":"49e0d6256d6bb8c8","repo":"flowable/flowable-engine","slug":"deploymentid-is-null-49e0d6","errorCode":null,"errorMessage":"deploymentId is null","messagePattern":"deploymentId is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java","lineNumber":44,"sourceCode":"/**\n * @author Joram Barrez\n */\npublic class ChangeDeploymentTenantIdCmd implements Command<Void>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String deploymentId;\n    protected String newTenantId;\n\n    public ChangeDeploymentTenantIdCmd(String deploymentId, String newTenantId) {\n        this.deploymentId = deploymentId;\n        this.newTenantId = newTenantId;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (deploymentId == null) {\n            throw new ActivitiIllegalArgumentException(\"deploymentId is null\");\n        }\n\n        // Update all entities\n\n        DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findDeploymentById(deploymentId);\n        if (deployment == null) {\n            throw new ActivitiObjectNotFoundException(\"Could not find deployment with id \" + deploymentId, Deployment.class);\n        }\n        String oldTenantId = deployment.getTenantId();\n        deployment.setTenantId(newTenantId);\n\n        // Doing process instances, executions and tasks with direct SQL updates (otherwise would not be performant)\n        commandContext.getProcessDefinitionEntityManager().updateProcessDefinitionTenantIdForDeployment(deploymentId, newTenantId);\n        commandContext.getExecutionEntityManager().updateExecutionTenantIdForDeployment(deploymentId, newTenantId);\n        commandContext.getTaskEntityManager().updateTaskTenantIdForDeployment(deploymentId, newTenantId);\n        commandContext.getJobEntityManager().updateJobTenantIdForDeployment(deploymentId, newTenantId);\n        commandContext.getTimerJobEntityManager().updateTimerJobTenantIdForDeployment(deploymentId, newTenantId);\n        commandContext.getSuspendedJobEntityManager().updateSuspendedJobTenantIdForDeployment(deploymentId, newTenantId);","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java#L26-L62","documentation":"Activiti/Flowable's ChangeDeploymentTenantIdCmd changes the tenantId of a deployment and its related definitions, instances and tasks. Before doing any work it validates that a deploymentId was supplied; a null id is rejected immediately as an illegal argument because no lookup or update is possible without it.","triggerScenarios":"Calling managementService.changeDeploymentTenantId(deploymentId, newTenantId) (or executing ChangeDeploymentTenantIdCmd directly) with a null deploymentId, e.g. an unresolved variable or an unset config field passed through.","commonSituations":"Deployments created via a different API that returns null id on failure; wiring a tenant-id change into a batch script where the deployment id comes from a properties file or env var that is empty; passing a variable that was never initialized.","solutions":["Ensure a non-null deploymentId is passed to changeDeploymentTenantId","Log/validate the id at the call site before invoking the command","Fix the upstream source (config property, variable, lookup) that yields null"],"exampleFix":"// before\nmanagementService.changeDeploymentTenantId(deploymentId, \"tenant-2\");\n// after\nif (deploymentId == null) throw new IllegalArgumentException(\"deploymentId required\");\nmanagementService.changeDeploymentTenantId(deploymentId, \"tenant-2\");","handlingStrategy":"validation","validationCode":"if (deploymentId == null || deploymentId.isEmpty()) throw new IllegalArgumentException(\"deploymentId required before changeDeploymentTenantId\");","typeGuard":"boolean hasDeploymentId(String id) { return id != null && !id.trim().isEmpty(); }","tryCatchPattern":"try { managementService.changeDeploymentTenantId(id, tenant); } catch (ActivitiIllegalArgumentException e) { log.error(\"Bad argument: {}\", e.getMessage()); }","preventionTips":["Validate ids at API/controller boundaries before invoking commands","Never pass through variables that may be uninitialized","Add unit tests for null-id arguments"],"tags":["validation","null-argument","deployment"],"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"}