{"record":{"id":"883cacee5e0c4b79","repo":"flowable/flowable-engine","slug":"the-channel-definition-id-is-mandatory-but-has","errorCode":null,"errorMessage":"The channel definition id is mandatory, but '' has been provided.","messagePattern":"The channel definition id is mandatory, but '' has been provided\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/GetChannelDefinitionResourceCmd.java","lineNumber":37,"sourceCode":"import org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.eventregistry.impl.persistence.entity.ChannelDefinitionEntity;\nimport org.flowable.eventregistry.impl.util.CommandContextUtil;\n\n/**\n * Gives access to a deployed event model, e.g., an Event definition JSON file, through a stream of bytes.\n * \n * @author Tijs Rademakers\n */\npublic class GetChannelDefinitionResourceCmd implements Command<InputStream>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String channelDefinitionId;\n\n    public GetChannelDefinitionResourceCmd(String channelDefinitionId) {\n        if (channelDefinitionId == null || channelDefinitionId.length() < 1) {\n            throw new FlowableIllegalArgumentException(\"The channel definition id is mandatory, but '\" + channelDefinitionId + \"' has been provided.\");\n        }\n        this.channelDefinitionId = channelDefinitionId;\n    }\n\n    @Override\n    public InputStream execute(CommandContext commandContext) {\n        ChannelDefinitionEntity channelDefinition = CommandContextUtil.getEventRegistryConfiguration().getDeploymentManager()\n                .findDeployedChannelDefinitionById(channelDefinitionId);\n\n        String deploymentId = channelDefinition.getDeploymentId();\n        String resourceName = channelDefinition.getResourceName();\n        InputStream channelDefinitionStream = new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);\n        return channelDefinitionStream;\n    }\n\n}\n","sourceCodeStart":19,"sourceCodeEnd":54,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/GetChannelDefinitionResourceCmd.java#L19-L54","documentation":"The GetChannelDefinitionResourceCmd constructor requires a non-empty channelDefinitionId; a null or empty string throws FlowableIllegalArgumentException. The command fetches the deployed resource stream for a channel definition, which is meaningless without an id.","triggerScenarios":"Constructing new GetChannelDefinitionResourceCmd(null) or new GetChannelDefinitionResourceCmd(\"\") directly, or calling repositoryService.getChannelDefinitionResource(\"\") / with a null id.","commonSituations":"Id field never populated from a request path variable; trimming stripped an id down to empty; a default empty-string initialization leaked into the command.","solutions":["Pass the actual channel definition id obtained from a query or deployment result","Validate the id is non-null and non-empty at the caller before invoking the command"],"exampleFix":"// before\nString id = request.getParameter(\"channelId\"); // may be null/empty\nInputStream is = repositoryService.getChannelDefinitionResource(id);\n// after\nString id = request.getParameter(\"channelId\");\nif (id == null || id.isEmpty()) throw new IllegalArgumentException(\"channelId required\");\nInputStream is = repositoryService.getChannelDefinitionResource(id);","handlingStrategy":"validation","validationCode":"boolean validId(String id) { return id != null && !id.trim().isEmpty(); }","typeGuard":null,"tryCatchPattern":"try {\n    InputStream is = repositoryService.getChannelDefinitionResource(channelDefinitionId);\n} catch (FlowableIllegalArgumentException e) {\n    LOGGER.error(\"invalid channel definition id supplied\");\n}","preventionTips":["Validate ids at API boundaries before constructing commands","Trim and check for empty strings (the guard rejects length < 1)","Source ids from repositoryService queries rather than free-form input"],"tags":["flowable","argument-validation","empty-string","channel"],"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"}