{"record":{"id":"3dbb0d6a75fc645a","repo":"flowable/flowable-engine","slug":"text-is-null-3dbb0d","errorCode":null,"errorMessage":"text is null","messagePattern":"text is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/repository/DeploymentBuilderImpl.java","lineNumber":93,"sourceCode":"\n    @Override\n    public DeploymentBuilder addClasspathResource(String resource) {\n        try (final InputStream inputStream = ReflectUtil.getResourceAsStream(resource)) {\n\t        if (inputStream == null) {\n\t            throw new FlowableIllegalArgumentException(\"resource '\" + resource + \"' not found\");\n\t        }\n\t        return addInputStream(resource, inputStream);\n\t        \n        } catch (IOException ex) {\n            throw new FlowableException(\"Failed to read resource \" + resource, ex);\n        }\n\n    }\n\n    @Override\n    public DeploymentBuilder addString(String resourceName, String text) {\n        if (text == null) {\n            throw new FlowableIllegalArgumentException(\"text is null\");\n        }\n        ResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(text.getBytes(StandardCharsets.UTF_8));\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public DeploymentBuilder addBytes(String resourceName, byte[] bytes) {\n        if (bytes == null) {\n            throw new FlowableIllegalArgumentException(\"bytes is null\");\n        }\n        ResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n\n        deployment.addResource(resource);","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/repository/DeploymentBuilderImpl.java#L75-L111","documentation":"Flowable's DeploymentBuilder.addString attaches an in-memory String as a deployment resource. The API rejects a null text argument with a FlowableIllegalArgumentException because a resource with no content cannot be stored. The content may be null because the caller passed a null literal or an unresolved variable.","triggerScenarios":"Calling deploymentBuilder.addString(resourceName, null); addBpmnModel internally converts the model to XML and calls addString, so a model that serializes to null text also triggers it; passing a String variable that was never initialized.","commonSituations":"Programmatic model creation where BpmnModel conversion produced no output; refactoring that removed the string constant; configuration property expected to hold the XML but was null; NPE-avoiding wrappers that pass null through.","solutions":["Ensure the String passed to addString is non-null before calling; check the variable that produces it.","If using addBpmnModel, verify the BpmnModel contains at least one process so XML conversion yields content.","Use addString(resourceName, text == null ? \"\" : text) only if an empty resource is acceptable; otherwise treat null as a bug.","Log the resource name and producer of the text to find where null originates."],"exampleFix":"// before\nString bpmnXml = config.getBpmnXml(); // may be null\nrepositoryService.createDeployment().addString(\"proc.bpmn20.xml\", bpmnXml).deploy();\n// after\nString bpmnXml = config.getBpmnXml();\nif (bpmnXml == null || bpmnXml.isEmpty()) {\n    throw new IllegalStateException(\"bpmnXml is not configured\");\n}\nrepositoryService.createDeployment().addString(\"proc.bpmn20.xml\", bpmnXml).deploy();","handlingStrategy":"validation","validationCode":"if (text == null || text.isEmpty()) throw new IllegalArgumentException(\"resource text for \" + resourceName + \" is empty\");","typeGuard":"boolean hasText(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try {\n    builder.addString(name, text).deploy();\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"addString rejected input: {}\", e.getMessage());\n    throw e;\n}","preventionTips":["Null-check strings produced by config or model serialization before adding them as resources.","Prefer addInputStream/addBytes with content you have verified.","Write a test that deploys every programmatically generated resource.","Never pass Optional.get-less or possibly-null variables directly into the builder."],"tags":["java","flowable","deployment","null-check","validation"],"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"}