{"record":{"id":"9bc293d7ccb2bd75","repo":"flowable/flowable-engine","slug":"provided-channel-definition-must-have-a-deployment","errorCode":null,"errorMessage":"Provided channel definition must have a deployment id.","messagePattern":"Provided channel definition must have a deployment id\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/deployer/ChannelDefinitionDeploymentHelper.java","lineNumber":106,"sourceCode":"\n        ChannelDefinitionEntity existingDefinition = null;\n\n        if (tenantId != null && !tenantId.equals(EventRegistryEngineConfiguration.NO_TENANT_ID)) {\n            existingDefinition = channelDefinitionEntityManager.findLatestChannelDefinitionByKeyAndTenantId(key, tenantId);\n        } else {\n            existingDefinition = channelDefinitionEntityManager.findLatestChannelDefinitionByKey(key);\n        }\n\n        return existingDefinition;\n    }\n\n    /**\n     * Gets the persisted version of the already-deployed channel definition.\n     */\n    public ChannelDefinitionEntity getPersistedInstanceOfChannelDefinition(ChannelDefinitionEntity channelDefinition) {\n        String deploymentId = channelDefinition.getDeploymentId();\n        if (StringUtils.isEmpty(channelDefinition.getDeploymentId())) {\n            throw new FlowableIllegalArgumentException(\"Provided channel definition must have a deployment id.\");\n        }\n\n        ChannelDefinitionEntityManager channelDefinitionEntityManager = CommandContextUtil.getEventRegistryConfiguration().getChannelDefinitionEntityManager();\n\n        ChannelDefinitionEntity persistedChannelDefinition = null;\n        if (channelDefinition.getTenantId() == null || EventRegistryEngineConfiguration.NO_TENANT_ID.equals(channelDefinition.getTenantId())) {\n            persistedChannelDefinition = channelDefinitionEntityManager.findChannelDefinitionByDeploymentAndKey(deploymentId, channelDefinition.getKey());\n        } else {\n            persistedChannelDefinition = channelDefinitionEntityManager.findChannelDefinitionByDeploymentAndKeyAndTenantId(deploymentId,\n                            channelDefinition.getKey(), channelDefinition.getTenantId());\n        }\n\n        return persistedChannelDefinition;\n    }\n}\n","sourceCodeStart":88,"sourceCodeEnd":122,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/deployer/ChannelDefinitionDeploymentHelper.java#L88-L122","documentation":"getPersistedInstanceOfChannelDefinition throws FlowableIllegalArgumentException when the given ChannelDefinitionEntity has a null/empty deploymentId. The method fetches the persisted (database) version of a deployed channel definition, which requires a deployment id to locate it.","triggerScenarios":"Calling getPersistedInstanceOfChannelDefinition with a channel definition that was never persisted/deployed, or one whose deploymentId field was not set during the deployment pipeline (e.g. built in memory for tests or a partially initialized entity).","commonSituations":"Custom deployment code that builds ChannelDefinitionEntity objects manually without setting deploymentId, calling the helper before ChannelDefinitionDeploymentHelper has assigned the deployment, or copying entities between sessions losing the id.","solutions":["Ensure channelDefinition.setDeploymentId(...) is called before invoking this method (normally done by the deployer during updateCachingAndArtifacts).","Only call this helper with definitions that have already gone through deployment persistence.","If constructing definitions in tests, set a deploymentId of an actually deployed deployment."],"exampleFix":"// before\nChannelDefinitionEntity def = channelDefinitionEntityManager.create();\nhelper.getPersistedInstanceOfChannelDefinition(def); // no deploymentId\n// after\ndef.setDeploymentId(deployment.getId());\nhelper.getPersistedInstanceOfChannelDefinition(def);","handlingStrategy":"validation","validationCode":"if (channelDefinition.getDeploymentId() == null || channelDefinition.getDeploymentId().isEmpty()) throw new IllegalArgumentException(\"channelDefinition.deploymentId required before persistence lookup\");","typeGuard":null,"tryCatchPattern":"try { helper.getPersistedInstanceOfChannelDefinition(def); } catch (FlowableIllegalArgumentException e) { log.error(\"Definition not deployed: {}\", e.getMessage()); }","preventionTips":["Set deploymentId on entities before deployment persistence steps","Only call persistence helpers inside the standard deployment pipeline","Avoid manually constructing ChannelDefinitionEntity outside tests without full fields"],"tags":["flowable","event-registry","deployment","missing-id"],"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-14T11:17:12.474Z"}