{"record":{"id":"691ab318e80c55f6","repo":"flowable/flowable-engine","slug":"deploymentid-is-null-691ab3","errorCode":null,"errorMessage":"deploymentId is null","messagePattern":"deploymentId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/SetDeploymentTenantIdCmd.java","lineNumber":46,"sourceCode":" * @author Tijs Rademakers\n * @author Joram Barrez\n */\npublic class SetDeploymentTenantIdCmd implements Command<Void>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String deploymentId;\n    protected String newTenantId;\n\n    public SetDeploymentTenantIdCmd(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 FlowableIllegalArgumentException(\"deploymentId is null\");\n        }\n\n        // Update all entities\n\n        EventDeploymentEntity deployment = CommandContextUtil.getDeploymentEntityManager(commandContext).findById(deploymentId);\n        if (deployment == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find deployment with id \" + deploymentId);\n        }\n\n        deployment.setTenantId(newTenantId);\n\n        CommandContextUtil.getEventDefinitionEntityManager(commandContext).updateEventDefinitionTenantIdForDeployment(deploymentId, newTenantId);\n\n        // Doing event definitions in memory, cause we need to clear the event definition cache\n        List<EventDefinition> eventDefinitions = new EventDefinitionQueryImpl().deploymentId(deploymentId).list();\n        for (EventDefinition eventDefinition : eventDefinitions) {\n            CommandContextUtil.getEventRegistryConfiguration().getEventDefinitionCache().remove(eventDefinition.getId());\n        }","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/SetDeploymentTenantIdCmd.java#L28-L64","documentation":"SetDeploymentTenantIdCmd.execute() validates that deploymentId is non-null and throws FlowableIllegalArgumentException if it is. Assigning a tenant id to an event deployment requires an existing deployment id.","triggerScenarios":"Calling setDeploymentTenantId with a null deployment id, usually from an unresolved variable, empty query result, or a caller that never captured the deployment id after deployment.","commonSituations":"Multi-tenant setup scripts where the deploy step failed silently; placeholder values ('${deploymentId}') not substituted in scripted configuration; refactoring dropped the id propagation.","solutions":["Obtain the deployment id from the EventDeploymentEntity returned by the deploy call or a deployment query before setting the tenant.","Validate deploymentId != null in the caller with a clear failure.","Fix the configuration/script so the deployment id is substituted correctly."],"exampleFix":"// before\neventRepositoryService.setDeploymentTenantId(\"${deploymentId}\", \"tenant-acme\"); // unsubstituted placeholder\n// after\nEventDeployment dep = eventRepositoryService.createDeploymentQuery().deploymentName(\"myEvents\").singleResult();\neventRepositoryService.setDeploymentTenantId(dep.getId(), \"tenant-acme\");","handlingStrategy":"validation","validationCode":"if (deploymentId == null || deploymentId.isBlank() || deploymentId.startsWith(\"${\")) {\n    throw new IllegalArgumentException(\"deploymentId unresolved: \" + deploymentId);\n}","typeGuard":"boolean hasValidDeploymentId(String id) {\n    return id != null && !id.isBlank() && !id.startsWith(\"${\");\n}","tryCatchPattern":"try {\n    eventRepositoryService.setDeploymentTenantId(deploymentId, tenantId);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Null/unresolved deploymentId for tenant assignment\", e);\n}","preventionTips":["Use the EventDeploymentEntity returned by deploy() to get the id.","Check for unsubstituted placeholders in scripted config.","Null-check ids before tenant assignment in multi-tenant setup scripts."],"tags":["flowable","event-registry","null-argument","tenant"],"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"}