{"record":{"id":"fc06946fc400dfb5","repo":"flowable/flowable-engine","slug":"no-channel-definition-found-for-id-channeldef","errorCode":null,"errorMessage":"No channel definition found for id = '${channelDefinitionId}'","messagePattern":"No channel definition found for id = '(.+?)'","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/SetChannelDefinitionCategoryCmd.java","lineNumber":48,"sourceCode":"    protected String channelDefinitionId;\n    protected String category;\n\n    public SetChannelDefinitionCategoryCmd(String channelDefinitionId, String category) {\n        this.channelDefinitionId = channelDefinitionId;\n        this.category = category;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n\n        if (channelDefinitionId == null) {\n            throw new FlowableIllegalArgumentException(\"Channel definition id is null\");\n        }\n\n        ChannelDefinitionEntity channelDefinition = CommandContextUtil.getChannelDefinitionEntityManager(commandContext).findById(channelDefinitionId);\n\n        if (channelDefinition == null) {\n            throw new FlowableObjectNotFoundException(\"No channel definition found for id = '\" + channelDefinitionId + \"'\");\n        }\n\n        // Update category\n        channelDefinition.setCategory(category);\n\n        // Remove channel from cache, it will be refetch later\n        DeploymentCache<ChannelDefinitionCacheEntry> channelDefinitionCache = CommandContextUtil.getEventRegistryConfiguration().getChannelDefinitionCache();\n        if (channelDefinitionCache != null) {\n            channelDefinitionCache.remove(channelDefinitionId);\n        }\n\n        CommandContextUtil.getChannelDefinitionEntityManager(commandContext).update(channelDefinition);\n\n        return null;\n    }\n\n}\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/SetChannelDefinitionCategoryCmd.java#L30-L66","documentation":"SetChannelDefinitionCategoryCmd.execute() looks up the channel definition by id; if findById returns null it throws FlowableObjectNotFoundException, meaning no channel definition with that id exists in the event registry.","triggerScenarios":"Calling setChannelDefinitionCategory with an id that was never created, that was deleted by a redeployment cleanup, or that belongs to a different database/engine instance.","commonSituations":"Hardcoded ids from another environment (dev vs prod databases); referencing a channel definition removed by cascade delete of a deployment; stale ids cached in application config after DB re-init.","solutions":["Query the current channel definition by key to get the valid id (createChannelDefinitionQuery().channelDefinitionKey(...).singleResult()).","Check you are connected to the expected database/engine where the channel definition exists.","Redeploy the event registry model containing the channel definition if it was deleted.","Verify the id value for truncation/encoding issues when sourced from external config."],"exampleFix":"// before\nrepositoryService.setChannelDefinitionCategory(\"chan-123\", \"marketing\"); // chan-123 not in DB\n// after\nChannelDefinition ch = eventRepositoryService.createChannelDefinitionQuery().channelDefinitionKey(\"myChannel\").latestVersion().singleResult();\nrepositoryService.setChannelDefinitionCategory(ch.getId(), \"marketing\");","handlingStrategy":"try-catch","validationCode":"ChannelDefinition ch = eventRepositoryService.createChannelDefinitionQuery().channelDefinitionId(id).singleResult();\nif (ch == null) throw new IllegalStateException(\"No channel definition with id \" + id);","typeGuard":"boolean channelExists(String id) {\n    return eventRepositoryService.createChannelDefinitionQuery().channelDefinitionId(id).count() > 0;\n}","tryCatchPattern":"try {\n    eventRepositoryService.setChannelDefinitionCategory(id, category);\n} catch (FlowableObjectNotFoundException e) {\n    log.warn(\"Channel definition {} no longer exists; re-resolving by key\", id, e);\n}","preventionTips":["Look up fresh ids by channel key instead of persisting ids across environments.","Re-resolve ids after any deployment cleanup job runs.","Confirm engine/database targeting before mutating definitions."],"tags":["flowable","event-registry","not-found","channel-definition"],"backgroundTag":"entity-not-found","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"}