{"record":{"id":"3a7cbe67df009696","repo":"quarkusio/quarkus","slug":"type-must-not-be-null","errorCode":null,"errorMessage":"type must not be null","messagePattern":"type must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/EntityPartBuilderImpl.java","lineNumber":111,"sourceCode":"\n    @Override\n    public EntityPart.Builder content(InputStream content) throws IllegalArgumentException {\n        if (content == null) {\n            throw new IllegalArgumentException(\"content must not be null\");\n        }\n        this.content = content;\n        this.contentType = null;\n        this.contentGenericType = null;\n        return this;\n    }\n\n    @Override\n    public <T> EntityPart.Builder content(T content, Class<? extends T> type) throws IllegalArgumentException {\n        if (content == null) {\n            throw new IllegalArgumentException(\"content must not be null\");\n        }\n        if (type == null) {\n            throw new IllegalArgumentException(\"type must not be null\");\n        }\n        this.content = content;\n        this.contentType = type;\n        this.contentGenericType = type;\n        return this;\n    }\n\n    @Override\n    public <T> EntityPart.Builder content(T content, GenericType<T> type) throws IllegalArgumentException {\n        if (content == null) {\n            throw new IllegalArgumentException(\"content must not be null\");\n        }\n        if (type == null) {\n            throw new IllegalArgumentException(\"type must not be null\");\n        }\n        this.content = content;\n        this.contentType = type.getRawType();\n        this.contentGenericType = type.getType();","sourceCodeStart":93,"sourceCodeEnd":129,"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#L93-L129","documentation":"EntityPart.Builder.content(T, Class<? extends T>) requires an explicit Class used to select the matching MessageBodyWriter; the type argument must not be null or IllegalArgumentException is thrown. The content object itself is validated first.","triggerScenarios":"Calling partBuilder.content(entity, null) — passing the entity without a concrete Class, e.g. when the type is derived from a nullable variable or generics erasure.","commonSituations":"Generic helper methods that capture the type from a parameter which is null; using getClass() on a null entity or forwarding an uninitialized Class variable; reflection-based builders.","solutions":["Pass the concrete class explicitly, e.g. content(dto, MyDto.class).","Derive the class safely from the entity: entity.getClass() (valid since entity must be non-null anyway).","In generic helpers, capture the Class as a method parameter and validate it.","Fix the caller that passes a null Class variable."],"exampleFix":"// before\nbuilder.content(entity, typeClass); // typeClass may be null\n\n// after\nbuilder.content(entity, entity.getClass());","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(type, \"content type must not be null\");\nbuilder.content(entity, type);","typeGuard":"<T> Class<? extends T> typeOf(T entity) {\n    @SuppressWarnings(\"unchecked\")\n    Class<? extends T> c = (Class<? extends T>) entity.getClass();\n    return c;\n}","tryCatchPattern":"try {\n    builder.content(entity, type);\n} catch (IllegalArgumentException e) {\n    builder.content(entity, entity.getClass());\n}","preventionTips":["Always pass an explicit class literal (MyDto.class) to content(T, Class).","In generic helpers, take the Class as a parameter rather than inferring it.","Use entity.getClass() when no explicit type is available."],"tags":["resteasy-reactive","jax-rs","multipart","entitypart","content","null-argument"],"backgroundTag":"null-required-argument","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"}