{"record":{"id":"d45c8d0ddca0a89d","repo":"conductor-oss/conductor","slug":"cannot-wrap-primitive-type","errorCode":null,"errorMessage":"cannot wrap primitive type: ","messagePattern":"cannot wrap primitive type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"annotations-processor/src/main/java/com/netflix/conductor/annotationsprocessor/protogen/types/WrappedType.java","lineNumber":30,"sourceCode":" */\npackage com.netflix.conductor.annotationsprocessor.protogen.types;\n\nimport java.lang.reflect.Type;\nimport java.util.Set;\n\nimport javax.lang.model.element.Modifier;\n\nimport com.squareup.javapoet.MethodSpec;\nimport com.squareup.javapoet.TypeName;\n\npublic class WrappedType extends AbstractType {\n    private AbstractType realType;\n    private MessageType wrappedType;\n\n    public static WrappedType wrap(GenericType realType) {\n        Type valueType = realType.getValueType().getJavaType();\n        if (!(valueType instanceof Class))\n            throw new IllegalArgumentException(\"cannot wrap primitive type: \" + valueType);\n\n        String className = ((Class) valueType).getSimpleName() + realType.getWrapperSuffix();\n        MessageType wrappedType = TypeMapper.INSTANCE.get(className);\n        if (wrappedType == null)\n            throw new IllegalArgumentException(\"missing wrapper class: \" + className);\n        return new WrappedType(realType, wrappedType);\n    }\n\n    public WrappedType(AbstractType realType, MessageType wrappedType) {\n        super(realType.getJavaType(), wrappedType.getJavaProtoType());\n        this.realType = realType;\n        this.wrappedType = wrappedType;\n    }\n\n    @Override\n    public String getProtoType() {\n        return wrappedType.getProtoType();\n    }","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/annotations-processor/src/main/java/com/netflix/conductor/annotationsprocessor/protogen/types/WrappedType.java#L12-L48","documentation":"Thrown as IllegalArgumentException by WrappedType.wrap when the value type of a generic (collection/map) is not an instance of Class. protogen wraps collection element types in a generated mapper; a non-Class value type (a TypeVariable, a generic array, a primitive) has no simple name to build the wrapper class name from, so wrapping is refused.","triggerScenarios":"A collection or map field whose generic element is itself an unresolved type variable (e.g. List<T> on a generic message), a primitive array element, or a wildcard/parameterized value type rather than a concrete class.","commonSituations":"Adding a generic @ProtoMessage with type parameters; nesting a parameterized type as a collection element (List<List<String>>); protogen encountering a field whose element type was not concretely resolvable.","solutions":["Use a concrete element class on collection/map fields: List<String>, Map<String, Integer>, List<MyMessage>.","Remove type parameters from @ProtoMessage classes that protogen must map, or bind them to concrete types.","Avoid nested raw generics; flatten List<List<X>> into a wrapper message containing List<X>."],"exampleFix":"// before\n@ProtoMessage public class Container<T> {\n    List<T> items; // T is a TypeVariable, not a Class\n}\n// after\n@ProtoMessage public class Container {\n    List<Item> items;\n}","handlingStrategy":"type-guard","validationCode":"import java.lang.reflect.Field;\nimport java.lang.reflect.ParameterizedType;\nimport java.lang.reflect.TypeVariable;\nimport java.util.Collection;\nstatic void assertConcreteElementTypes(Class<?> msg) {\n    for (Field f : msg.getDeclaredFields()) {\n        if (Collection.class.isAssignableFrom(f.getType()) || Map.class.isAssignableFrom(f.getType())) {\n            if (f.getGenericType() instanceof ParameterizedType pt) {\n                var elem = pt.getActualTypeArguments()[pt.getActualTypeArguments().length - 1];\n                if (elem instanceof TypeVariable<?>)\n                    throw new IllegalStateException(\"Unresolved type variable on \" + f + \": \" + elem);\n            }\n        }\n    }\n}","typeGuard":"static boolean isConcreteClassType(java.lang.reflect.Type t) {\n    return t instanceof Class<?>;\n}","tryCatchPattern":null,"preventionTips":["Use concrete element classes on collection/map fields.","Avoid type parameters on @ProtoMessage classes that protogen must map.","Flatten nested generics into wrapper messages."],"tags":["protogen","protobuf","type-mapping","codegen","generics"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}