{"record":{"id":"e391fd9ab870fe9c","repo":"flowable/flowable-engine","slug":"channel-definition-id-is-null","errorCode":null,"errorMessage":"Channel definition id is null","messagePattern":"Channel definition id is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/SetChannelDefinitionCategoryCmd.java","lineNumber":42,"sourceCode":"/**\n * @author Tijs Rademakers\n * @author Joram Barrez\n */\npublic class SetChannelDefinitionCategoryCmd implements Command<Void> {\n\n    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);","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/SetChannelDefinitionCategoryCmd.java#L24-L60","documentation":"SetChannelDefinitionCategoryCmd.execute() validates that a channel definition id was supplied; if channelDefinitionId is null it throws FlowableIllegalArgumentException before querying. The category of an existing channel definition cannot be changed without identifying it by id.","triggerScenarios":"Calling the set-channel-definition-category API with a null id, e.g. a variable from a lookup that returned nothing, or a caller mixing up key vs id.","commonSituations":"Passing an event definition key where the API expects a channel definition id; a prior findById/getChannelDefinition call returning null and its result being forwarded; refactoring that renamed a field but not the argument.","solutions":["Fetch the channel definition by key/name first to obtain its id, then pass that id.","Validate the id is non-null in your code before calling the command.","Correct the call site so the channel definition id (not key) is passed."],"exampleFix":"// before\nrepositoryService.setChannelDefinitionCategory(null, \"marketing\");\n// after\nChannelDefinition ch = eventRepositoryService.createChannelDefinitionQuery().channelDefinitionKey(\"myChannel\").latestVersion().singleResult();\nrepositoryService.setChannelDefinitionCategory(ch.getId(), \"marketing\");","handlingStrategy":"validation","validationCode":"if (channelDefinitionId == null || channelDefinitionId.isBlank()) {\n    throw new IllegalArgumentException(\"channelDefinitionId is required\");\n}","typeGuard":"boolean hasChannelId(ChannelDefinition ch) {\n    return ch != null && ch.getId() != null && !ch.getId().isBlank();\n}","tryCatchPattern":"try {\n    eventRepositoryService.setChannelDefinitionCategory(channelDefinitionId, category);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Channel definition id missing\", e);\n}","preventionTips":["Resolve ids from queries, never pass through nullable lookup results unchecked.","Distinguish keys from ids in variable names and APIs.","Null-check query results before forwarding their ids."],"tags":["flowable","event-registry","null-argument","channel-definition"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}