{"record":{"id":"dd18623155833559","repo":"flowable/flowable-engine","slug":"the-case-definition-id-is-mandatory-but-has-be","errorCode":null,"errorMessage":"The case definition id is mandatory, but '' has been provided.","messagePattern":"The case definition id is mandatory, but '' has been provided\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetDeploymentCaseDiagramCmd.java","lineNumber":41,"sourceCode":"import org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\n/**\n * Gives access to a deployed case diagram, e.g., a PNG image, through a stream of bytes.\n * \n * @author Tijs Rademakers\n */\npublic class GetDeploymentCaseDiagramCmd implements Command<InputStream>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    private static final Logger LOGGER = LoggerFactory.getLogger(GetDeploymentCaseDiagramCmd.class);\n\n    protected String caseDefinitionId;\n\n    public GetDeploymentCaseDiagramCmd(String caseDefinitionId) {\n        if (caseDefinitionId == null || caseDefinitionId.length() == 0) {\n            throw new FlowableIllegalArgumentException(\"The case definition id is mandatory, but '\" + caseDefinitionId + \"' has been provided.\");\n        }\n        this.caseDefinitionId = caseDefinitionId;\n    }\n\n    @Override\n    public InputStream execute(CommandContext commandContext) {\n        CaseDefinition caseDefinition = CommandContextUtil.getCmmnEngineConfiguration(commandContext).getDeploymentManager().findDeployedCaseDefinitionById(caseDefinitionId);\n        String deploymentId = caseDefinition.getDeploymentId();\n        String resourceName = caseDefinition.getDiagramResourceName();\n        if (resourceName == null) {\n            LOGGER.info(\"Resource name is null! No case diagram stream exists.\");\n            return null;\n        } else {\n            InputStream caseDiagramStream = new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);\n            return caseDiagramStream;\n        }\n    }\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetDeploymentCaseDiagramCmd.java#L23-L59","documentation":"GetDeploymentCaseDiagramCmd enforces in its constructor that a caseDefinitionId is supplied: null or empty-string ids throw FlowableIllegalArgumentException with the offending value embedded in the message ('' for empty). Unlike the other commands, this validation happens at command construction time, so the exception is thrown before the command ever executes.","triggerScenarios":"new GetDeploymentCaseDiagramCmd(null) or new GetDeploymentCaseDiagramCmd(\"\") — typically via repositoryService.getCaseDiagramResource/case diagram APIs fed an empty id variable.","commonSituations":"Empty string from a request parameter defaulting to \"\" instead of null; trimmed-to-empty user input; id variable never populated in a template or script task.","solutions":["Pass a non-null, non-empty caseDefinitionId when constructing the command","Trim and validate the id at the caller boundary (reject empty strings, not just null)","Resolve the id from the case definition query before requesting the diagram"],"exampleFix":"// before\nInputStream diagram = repositoryService.getCaseDiagram(caseDefinitionId); // id may be \"\"\n// after\nif (caseDefinitionId == null || caseDefinitionId.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"caseDefinitionId is required\");\n}\nInputStream diagram = repositoryService.getCaseDiagram(caseDefinitionId);","handlingStrategy":"validation","validationCode":"if (id == null || id.trim().isEmpty()) { throw new IllegalArgumentException(\"caseDefinitionId required\"); }","typeGuard":"boolean isNonEmptyId = s != null && !s.trim().isEmpty();","tryCatchPattern":"try { return repositoryService.getCaseDiagram(id); } catch (FlowableIllegalArgumentException e) { log.error(\"Invalid id '{}': {}\", id, e.getMessage()); throw e; }","preventionTips":["Treat empty string as invalid, not just null","Trim user-supplied ids before use","Construct commands only after id validation"],"tags":["java","flowable","empty-string","argument-validation"],"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"}