{"record":{"id":"df58f1bcc4975a3c","repo":"flowable/flowable-engine","slug":"the-deployment-contains-channel-definition-with-th","errorCode":null,"errorMessage":"The deployment contains channel definition with the same key, this is not allowed","messagePattern":"The deployment contains channel definition with the same key, this is not allowed","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/deployer/ChannelDefinitionDeploymentHelper.java","lineNumber":45,"sourceCode":"import org.flowable.eventregistry.impl.util.CommandContextUtil;\n\n/**\n * Methods for working with deployments. Much of the actual work of {@link EventDefinitionDeployer} is done by orchestrating the different pieces of work this class does; by having them here, we allow\n * other deployers to make use of them.\n */\npublic class ChannelDefinitionDeploymentHelper {\n\n    /**\n     * Verifies that no two channel definitions share the same key, to prevent database unique index violation.\n     * \n     * @throws FlowableException\n     *             if any two channel definitions have the same key\n     */\n    public void verifyChannelDefinitionsDoNotShareKeys(Collection<ChannelDefinitionEntity> channelDefinitions) {\n        Set<String> keySet = new LinkedHashSet<>();\n        for (ChannelDefinitionEntity channelDefinition : channelDefinitions) {\n            if (keySet.contains(channelDefinition.getKey())) {\n                throw new FlowableException(\"The deployment contains channel definition with the same key, this is not allowed\");\n            }\n            keySet.add(channelDefinition.getKey());\n        }\n    }\n\n    /**\n     * Updates all the channel definition entities to match the deployment's values for tenant, engine version, and deployment id.\n     */\n    public void copyDeploymentValuesToEventDefinitions(EventDeploymentEntity deployment, List<ChannelDefinitionEntity> channelDefinitions) {\n        String tenantId = deployment.getTenantId();\n        String deploymentId = deployment.getId();\n\n        for (ChannelDefinitionEntity channelDefinition : channelDefinitions) {\n\n            // event definition inherits the tenant id\n            if (tenantId != null) {\n                channelDefinition.setTenantId(tenantId);\n            }","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/deployer/ChannelDefinitionDeploymentHelper.java#L27-L63","documentation":"ChannelDefinitionDeploymentHelper.verifyChannelDefinitionsDoNotShareKeys throws FlowableException when a single deployment contains two or more channel definitions with the same key. Keys must be unique within a deployment because a key identifies the definition and its versioning.","triggerScenarios":"Deploying an event registry resource (or set of resources) that declares two channels with the same key, e.g. duplicated channel entries in one .eventreg model or two resources in one deployment defining the same channel key.","commonSituations":"Copy-pasting a channel block in the event registry JSON and forgetting to change the key, merging model files that both define the same channel, or programmatically adding the same channel definition twice to one deployment.","solutions":["Rename one of the duplicate channel keys in the event registry resource and redeploy.","Split the definitions into separate deployments if they are intentionally distinct resources.","Before deploying, collect channel keys from the model and assert uniqueness."],"exampleFix":"// before (event registry json)\n// <channel key=\"orders\" ... /> ... <channel key=\"orders\" ... />\n// after\n// <channel key=\"orders-inbound\" ... /> <channel key=\"orders-outbound\" ... />","handlingStrategy":"validation","validationCode":"Set<String> keys = channelDefinitions.stream().map(ChannelDefinitionEntity::getKey).collect(Collectors.toSet());\nif (keys.size() != channelDefinitions.size()) throw new IllegalStateException(\"Duplicate channel keys in deployment\");","typeGuard":null,"tryCatchPattern":"try { repositoryService.deploy(deployment); } catch (FlowableException e) { log.error(\"Deployment rejected: {}\", e.getMessage()); }","preventionTips":["Uniquely name every channel key in event registry resources","Check for duplicated channel blocks after merging model files","Run key-uniqueness checks in CI before deploying"],"tags":["flowable","event-registry","deployment","duplicate-key"],"backgroundTag":"conflicting-config-options","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"}