{"record":{"id":"3a298b5578015348","repo":"flowable/flowable-engine","slug":"deploymentid-is-null-3a298b","errorCode":null,"errorMessage":"deploymentId is null","messagePattern":"deploymentId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetDeploymentResourceCmd.java","lineNumber":42,"sourceCode":"import org.flowable.common.engine.impl.interceptor.CommandContext;\n\n/**\n * @author Joram Barrez\n */\npublic class GetDeploymentResourceCmd implements Command<InputStream> {\n\n    protected String deploymentId;\n    protected String resourceName;\n\n    public GetDeploymentResourceCmd(String deploymentId, String resourceName) {\n        this.deploymentId = deploymentId;\n        this.resourceName = resourceName;\n    }\n\n    @Override\n    public InputStream execute(CommandContext commandContext) {\n        if (deploymentId == null) {\n            throw new FlowableIllegalArgumentException(\"deploymentId is null\");\n        }\n        if (resourceName == null) {\n            throw new FlowableIllegalArgumentException(\"resourceName is null\");\n        }\n\n        CmmnResourceEntity resource = CommandContextUtil.getCmmnResourceEntityManager(commandContext)\n                .findResourceByDeploymentIdAndResourceName(deploymentId, resourceName);\n        if (resource == null) {\n            if (CommandContextUtil.getCmmnDeploymentEntityManager(commandContext).findById(deploymentId) == null) {\n                throw new FlowableObjectNotFoundException(\"deployment does not exist: \" + deploymentId, CmmnDeploymentEntity.class);\n            } else {\n                throw new FlowableObjectNotFoundException(\"no resource found with name '\" + resourceName + \"' in deployment '\" + deploymentId + \"'\", CmmnResourceEntity.class);\n            }\n        }\n        return new ByteArrayInputStream(resource.getBytes());\n    }\n\n}","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetDeploymentResourceCmd.java#L24-L60","documentation":"GetDeploymentResourceCmd validates both required inputs before querying the CmmnResourceEntityManager. When deploymentId is null it throws FlowableIllegalArgumentException('deploymentId is null'); resourceName null produces the sibling error. The command needs both to locate the exact resource bytes within a deployment.","triggerScenarios":"repositoryService.getResource(deploymentId, resourceName) (CMMN repository service) called with a null deploymentId — e.g. deployment lookup failed upstream and its result was passed along, or the deployment id field was never set.","commonSituations":"Chain like createDeploymentQuery().singleResult() returning null and .getId() being replaced by a null variable; integration code skipping the deployment step; multi-tenant lookup that filtered out the deployment.","solutions":["Obtain a valid deploymentId from the deployment query before fetching the resource","Handle the case where the deployment query returns no result instead of passing a null id","Validate deploymentId (and resourceName) non-null before the API call"],"exampleFix":"// before\nDeployment dep = repositoryService.createDeploymentQuery().deploymentName(name).singleResult();\nInputStream res = repositoryService.getResource(dep.getId(), resource); // NPE risk / null id\n// after\nDeployment dep = repositoryService.createDeploymentQuery().deploymentName(name).singleResult();\nif (dep != null) {\n    InputStream res = repositoryService.getResource(dep.getId(), resource);\n}","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(deploymentId, \"deploymentId is required\");\nObjects.requireNonNull(resourceName, \"resourceName is required\");","typeGuard":"boolean canFetchResource = deploymentId != null && resourceName != null;","tryCatchPattern":"try { return repositoryService.getResource(deploymentId, resourceName); } catch (FlowableIllegalArgumentException e) { log.error(\"Bad getResource args: {}\", e.getMessage()); throw e; }","preventionTips":["Null-check deployment query results before using .getId()","Fail fast when upstream lookups return nothing","Validate both id and name at the API boundary"],"tags":["java","flowable","null-check","deployment","resources"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}