{"record":{"id":"8cb76b308b317892","repo":"flowable/flowable-engine","slug":"deploymentid-is-null-8cb76b","errorCode":null,"errorMessage":"DeploymentId is null","messagePattern":"DeploymentId is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ModelQueryImpl.java","lineNumber":138,"sourceCode":"        if (version == null) {\n            throw new ActivitiIllegalArgumentException(\"version is null\");\n        } else if (version <= 0) {\n            throw new ActivitiIllegalArgumentException(\"version must be positive\");\n        }\n        this.version = version;\n        return this;\n    }\n\n    @Override\n    public ModelQuery latestVersion() {\n        this.latest = true;\n        return this;\n    }\n\n    @Override\n    public ModelQuery deploymentId(String deploymentId) {\n        if (deploymentId == null) {\n            throw new ActivitiIllegalArgumentException(\"DeploymentId is null\");\n        }\n        this.deploymentId = deploymentId;\n        return this;\n    }\n\n    @Override\n    public ModelQuery notDeployed() {\n        if (deployed) {\n            throw new ActivitiIllegalArgumentException(\"Invalid usage: cannot use deployed() and notDeployed() in the same query\");\n        }\n        this.notDeployed = true;\n        return this;\n    }\n\n    @Override\n    public ModelQuery deployed() {\n        if (notDeployed) {\n            throw new ActivitiIllegalArgumentException(\"Invalid usage: cannot use deployed() and notDeployed() in the same query\");","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ModelQueryImpl.java#L120-L156","documentation":"ModelQueryImpl.deploymentId(String) narrows the model query to models deployed with a specific deployment. Flowable throws ActivitiIllegalArgumentException when the deploymentId is null, since a null id cannot be used as an equality filter in the generated SQL.","triggerScenarios":"Calling modelQuery.deploymentId(null) — typically when the deployment id variable is null because no deployment was found or created yet.","commonSituations":"Looking up a Deployment via a repositoryService query that returned null and passing the result straight through; refactoring code where a deployment id field was never initialized.","solutions":["Pass a non-null, existing deployment id (e.g. from Deployment.getId()).","Null-check the deployment object/id before calling deploymentId().","If no deployment filter is desired, skip the deploymentId() call.","Wrap query construction in try-catch for ActivitiIllegalArgumentException to handle it gracefully."],"exampleFix":"// before\nDeployment d = repoService.createDeploymentQuery().deploymentName(name).singleResult();\nquery.deploymentId(d.getId()); // NPE-free but getId() may be fine; d may be null\n// after\nDeployment d = repoService.createDeploymentQuery().deploymentName(name).singleResult();\nif (d != null) {\n    query.deploymentId(d.getId());\n}","handlingStrategy":"validation","validationCode":"if (deploymentId != null && !deploymentId.isEmpty()) {\n    query.deploymentId(deploymentId);\n}","typeGuard":"boolean hasDeploymentId(Deployment d) { return d != null && d.getId() != null; }","tryCatchPattern":"try {\n    query.deploymentId(deploymentId);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    throw new BadRequestException(\"deploymentId filter requires a non-null id\", e);\n}","preventionTips":["Check the Deployment object for null before reading its id.","Skip optional filters instead of applying them with null values.","Centralize query building in a helper that ignores null filters."],"tags":["activiti","flowable","query-builder","null-argument"],"backgroundTag":"null-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"}