{"record":{"id":"beebeab30c749cfc","repo":"flowable/flowable-engine","slug":"deploymentid-is-null-beebea","errorCode":null,"errorMessage":"DeploymentId is null","messagePattern":"DeploymentId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/ModelQueryImpl.java","lineNumber":140,"sourceCode":"        if (version == null) {\n            throw new FlowableIllegalArgumentException(\"version is null\");\n        } else if (version <= 0) {\n            throw new FlowableIllegalArgumentException(\"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 FlowableIllegalArgumentException(\"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 FlowableIllegalArgumentException(\"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 FlowableIllegalArgumentException(\"Invalid usage: cannot use deployed() and notDeployed() in the same query\");","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/ModelQueryImpl.java#L122-L158","documentation":"ModelQueryImpl.deploymentId() requires a non-null deployment id string to filter models by the deployment that deployed them. Passing null would produce an invalid WHERE clause, so the library throws FlowableIllegalArgumentException immediately. A null here almost always means the caller never resolved a deployment id.","triggerScenarios":"Calling ModelQuery.deploymentId(null) directly, or passing a variable/lookup result that is null because the deployment was not created, was deleted, or the id variable was never initialized.","commonSituations":"Storing a deployment id in config or a request parameter and it is missing; looking up a deployment by name/key and using the result without a null check; flowable deploy step in CI/CD where the deployment failed earlier so the id is null.","solutions":["Ensure a valid deployment id is resolved before building the query (e.g. from RepositoryService.createDeployment().deploy() or createDeploymentQuery()).","Guard the value: if (deploymentId != null) query.deploymentId(deploymentId); else use a different filter.","If the id should be optional, omit the deploymentId() call rather than passing null.","Check that the deployment actually succeeded before querying models by its id."],"exampleFix":"// before\nString deploymentId = getDeploymentIdSomehow(); // may be null\nModelQuery query = repositoryService.createModelQuery().deploymentId(deploymentId);\n\n// after\nString deploymentId = getDeploymentIdSomehow();\nModelQuery query = repositoryService.createModelQuery();\nif (deploymentId != null) {\n    query.deploymentId(deploymentId);\n}","handlingStrategy":"type-guard","validationCode":"Objects.requireNonNull(deploymentId, \"deploymentId must be resolved before querying models\");\nModelQuery query = repositoryService.createModelQuery().deploymentId(deploymentId);","typeGuard":"boolean hasDeploymentId(String id) {\n    return id != null && !id.trim().isEmpty();\n}","tryCatchPattern":"try {\n    return repositoryService.createModelQuery().deploymentId(deploymentId).list();\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"deploymentId was null: {}\", e.getMessage());\n    return Collections.emptyList();\n}","preventionTips":["Resolve deployment ids from RepositoryService only after a successful deploy().","Never cache deployment ids across environments; look them up at runtime.","Null-check ids loaded from config or request parameters before applying query filters.","Treat deploymentId as optional and skip the filter when absent."],"tags":["flowable","query-builder","null-check","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-18T11:17:12.947Z"}