{"record":{"id":"5060f49b69afd0c5","repo":"quarkusio/quarkus","slug":"no-content-has-been-set","errorCode":null,"errorMessage":"No content has been set","messagePattern":"No content has been set","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/EntityPartBuilderImpl.java","lineNumber":175,"sourceCode":"                    ByteArrayOutputStream baos = new ByteArrayOutputStream();\n                    writer.writeTo(content, rawType, genericType, EMPTY_ANNOTATIONS, mediaType,\n                            new QuarkusMultivaluedHashMap<>(), baos);\n                    return new ByteArrayInputStream(baos.toByteArray());\n                } catch (IOException e) {\n                    throw new IllegalArgumentException(\"Failed to serialize content of type \" + rawType.getName(), e);\n                }\n            } else {\n                return new ByteArrayInputStream(content.toString().getBytes(StandardCharsets.UTF_8));\n            }\n        } else {\n            return new ByteArrayInputStream(content.toString().getBytes(StandardCharsets.UTF_8));\n        }\n    }\n\n    @Override\n    public EntityPart build() throws IllegalStateException, IOException, WebApplicationException {\n        if (content == null) {\n            throw new IllegalStateException(\"No content has been set\");\n        }\n\n        InputStream resolvedContent;\n        if (content instanceof InputStream) {\n            resolvedContent = (InputStream) content;\n        } else {\n            resolvedContent = serialiseContent();\n        }\n\n        MultivaluedMap<String, String> builtHeaders = new QuarkusMultivaluedHashMap<>();\n        builtHeaders.putAll(headers);\n\n        builtHeaders.putSingle(\"Content-Type\", mediaType.toString());\n        builtHeaders.putSingle(\"Content-Disposition\", EntityPartImpl.buildContentDisposition(name, fileName));\n\n        return new EntityPartImpl(name, fileName, builtHeaders, mediaType, resolvedContent, serialisers);\n    }\n}","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/EntityPartBuilderImpl.java#L157-L193","documentation":"EntityPart.build() throws IllegalStateException if content(Object) was never called on the builder. An EntityPart without content cannot produce a valid multipart body, so the builder refuses to build. This is a lifecycle misuse of the builder, not a data problem.","triggerScenarios":"Calling EntityPart.withName(\"p\").mediaType(...).build() without ever invoking content(...), or calling content() inside a code branch that was skipped at runtime.","commonSituations":"Dynamic multipart assembly where a part is added but its content assignment happens under a condition; copy-pasted builder code where the content line was deleted; wrapper APIs that forget to forward content.","solutions":["Call content(...) with a non-null value before build() on every EntityPart.Builder.","Restructure code so parts are only constructed when their content is available.","Wrap builder chains in a helper that asserts content was set before build()."],"exampleFix":"// before\nEntityPart part = EntityPart.withName(\"meta\")\n        .mediaType(MediaType.APPLICATION_JSON_TYPE)\n        .build(); // IllegalStateException: No content has been set\n// after\nEntityPart part = EntityPart.withName(\"meta\")\n        .content(metadata, new GenericType<Metadata>() {})\n        .mediaType(MediaType.APPLICATION_JSON_TYPE)\n        .build();","handlingStrategy":"validation","validationCode":"// Builder helper that guarantees content\nEntityPart.Builder b = EntityPart.withName(\"part\");\nObjects.requireNonNull(content, \"content must be set before build()\");\nb.content(content);\nEntityPart part = b.build();","typeGuard":null,"tryCatchPattern":"try {\n    EntityPart part = builder.build();\n} catch (IllegalStateException e) {\n    if (\"No content has been set\".equals(e.getMessage())) {\n        throw new ConfigurationException(\"multipart part built without content; check code path\");\n    }\n    throw e;\n}","preventionTips":["Set content immediately after withName so the builder is never left without it.","Build parts in a single expression to avoid conditional skips.","Add a unit test asserting every generated part has content."],"tags":["resteasy-reactive","multipart","illegal-state","builder","jax-rs"],"backgroundTag":"builder-state-not-initialized","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}