{"record":{"id":"c474ec6dce648e63","repo":"Activiti/Activiti","slug":"bytes-is-null","errorCode":null,"errorMessage":"bytes is null","messagePattern":"bytes is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/repository/DeploymentBuilderImpl.java","lineNumber":163,"sourceCode":"\n    public DeploymentBuilder addString(String resourceName, String text) {\n        if (text == null) {\n            throw new ActivitiIllegalArgumentException(\"text is null\");\n        }\n        ResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        try {\n            resource.setBytes(text.getBytes(DEFAULT_ENCODING));\n        } catch (UnsupportedEncodingException e) {\n            throw new ActivitiException(\"Unable to get process bytes.\", e);\n        }\n        deployment.addResource(resource);\n        return this;\n    }\n\n    public DeploymentBuilder addBytes(String resourceName, byte[] bytes) {\n        if (bytes == null) {\n            throw new ActivitiIllegalArgumentException(\"bytes is null\");\n        }\n        ResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n\n        deployment.addResource(resource);\n        return this;\n    }\n\n    public DeploymentBuilder addZipInputStream(ZipInputStream zipInputStream) {\n        try {\n            ZipEntry entry = zipInputStream.getNextEntry();\n            while (entry != null) {\n                if (!entry.isDirectory()) {\n                    String entryName = entry.getName();\n                    byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);\n                    ResourceEntity resource = resourceEntityManager.create();\n                    resource.setName(entryName);","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/repository/DeploymentBuilderImpl.java#L145-L181","documentation":"Parameter guard in DeploymentBuilderImpl.addBytes: the byte content of the deployment resource is required, and null bytes would create an empty resource. Thrown when addBytes is called with a null byte array.","triggerScenarios":"builder.addBytes(name, null), typically when bytes come from a failed read, a null-returning helper, or an uninitialized field.","commonSituations":"Files.readAllBytes on a nonexistent file path guarded elsewhere; generated byte content (e.g. model XML) that failed; null returned from a cache or transform utility.","solutions":["Null-check the byte array before calling addBytes","Fix the upstream byte-producing code to return empty array or throw a clear error","Use addInputStream/addString/addClasspathResource if that suits the source better"],"exampleFix":"// before\nbuilder.addBytes(\"res.bin\", produceBytes()); // may be null\n// after\nbyte[] b = produceBytes();\nif (b != null) { builder.addBytes(\"res.bin\", b); }","handlingStrategy":"validation","validationCode":"if (bytes == null) throw new IllegalArgumentException(\"bytes must not be null\");","typeGuard":"boolean hasBytes(byte[] b) { return b != null; }","tryCatchPattern":"try { builder.addBytes(name, bytes); } catch (org.activiti.engine.ActivitiIllegalArgumentException e) { if (\"bytes is null\".equals(e.getMessage())) { /* fix byte source */ } else throw e; }","preventionTips":["Null-check output of byte-producing helpers before use","Prefer throwing early at the byte source instead of returning null","Use empty arrays rather than null to represent 'no content'"],"tags":["null-check","bytes","deployment","validation"],"backgroundTag":"null-argument","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}