{"record":{"id":"d0080877ec5feb47","repo":"flowable/flowable-engine","slug":"the-process-definition-id-is-mandatory-but-pro-d00808","errorCode":null,"errorMessage":"The process definition id is mandatory, but '${processDefinitionId}' has been provided.","messagePattern":"The process definition id is mandatory, but '(.+?)' has been provided\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetDeploymentProcessModelCmd.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.engine.impl.util.CommandContextUtil;\nimport org.flowable.engine.repository.ProcessDefinition;\n\n/**\n * Gives access to a deployed process model, e.g., a BPMN 2.0 XML file, through a stream of bytes.\n * \n * @author Falko Menge\n */\npublic class GetDeploymentProcessModelCmd implements Command<InputStream>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String processDefinitionId;\n\n    public GetDeploymentProcessModelCmd(String processDefinitionId) {\n        if (processDefinitionId == null || processDefinitionId.length() < 1) {\n            throw new FlowableIllegalArgumentException(\"The process definition id is mandatory, but '\" + processDefinitionId + \"' has been provided.\");\n        }\n        this.processDefinitionId = processDefinitionId;\n    }\n\n    @Override\n    public InputStream execute(CommandContext commandContext) {\n        ProcessDefinition processDefinition = CommandContextUtil.getProcessEngineConfiguration(commandContext).getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);\n        String deploymentId = processDefinition.getDeploymentId();\n        String resourceName = processDefinition.getResourceName();\n        InputStream processModelStream = new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);\n        return processModelStream;\n    }\n\n}\n","sourceCodeStart":19,"sourceCodeEnd":52,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetDeploymentProcessModelCmd.java#L19-L52","documentation":"FlowableIllegalArgumentException thrown by the GetDeploymentProcessModelCmd constructor when processDefinitionId is null or empty. The command retrieves the BPMN XML model stream for a definition, which requires a valid id. It fails fast before any database access.","triggerScenarios":"Calling repositoryService.getBpmnModel(null), getProcessModel(null), or the command directly with an empty string; id never populated after deployment or lookup returned no row.","commonSituations":"REST handlers passing unvalidated path variables; scripts exporting process models with ids read from a file/spreadsheet that had blanks; mixing up processDefinitionKey with processDefinitionId.","solutions":["Check for null/empty id and construct a real id via ProcessDefinitionQuery before calling.","If you only have the key, resolve the id: createProcessDefinitionQuery().processDefinitionKey(key).latestVersion().singleResult().getId().","Catch FlowableIllegalArgumentException and map to a client input error.","Sanitize inputs at the API boundary so empty strings never reach the engine."],"exampleFix":"// before\nInputStream model = repositoryService.getProcessModel(params.get(\"pdId\"));\n// after\nString id = params.get(\"pdId\");\nif (id == null || id.isBlank()) throw new ResponseStatusException(BAD_REQUEST, \"pdId required\");\nInputStream model = repositoryService.getProcessModel(id);","handlingStrategy":"validation","validationCode":"if (id == null || id.isEmpty())\n    throw new IllegalArgumentException(\"processDefinitionId is mandatory\");","typeGuard":"String resolveDefinitionId(String key) {\n    ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()\n        .processDefinitionKey(key).latestVersion().singleResult();\n    return pd == null ? null : pd.getId();\n}","tryCatchPattern":"try {\n    return repositoryService.getBpmnModel(id);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"A non-empty processDefinitionId is required\", e);\n}","preventionTips":["Validate non-null/non-empty ids before every engine command call.","Convert keys to ids via ProcessDefinitionQuery instead of guessing formats.","Reject empty strings in DTOs with bean validation (@NotBlank).","Cover model-export code paths with null-argument tests."],"tags":["flowable","validation","argument","process-model"],"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"}