{"record":{"id":"c3ac8aa3d275eb72","repo":"conductor-oss/conductor","slug":"cannot-map-type","errorCode":null,"errorMessage":"Cannot map type: ","messagePattern":"Cannot map type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"annotations-processor/src/main/java/com/netflix/conductor/annotationsprocessor/protogen/types/TypeMapper.java","lineNumber":82,"sourceCode":"                        Any.class,\n                        ClassName.get(Any.class),\n                        \"google.protobuf.Any\",\n                        \"google/protobuf/any.proto\"));\n    }\n\n    public AbstractType get(Type t) {\n        if (!types.containsKey(t)) {\n            if (t instanceof ParameterizedType) {\n                Type raw = ((ParameterizedType) t).getRawType();\n                if (PROTO_LIST_TYPES.containsKey(raw)) {\n                    types.put(t, new ListType(t));\n                } else if (raw.equals(Map.class)) {\n                    types.put(t, new MapType(t));\n                }\n            }\n        }\n        if (!types.containsKey(t)) {\n            throw new IllegalArgumentException(\"Cannot map type: \" + t);\n        }\n        return types.get(t);\n    }\n\n    public MessageType get(String className) {\n        for (Map.Entry<Type, AbstractType> pair : types.entrySet()) {\n            AbstractType t = pair.getValue();\n            if (t instanceof MessageType) {\n                if (((Class) t.getJavaType()).getSimpleName().equals(className))\n                    return (MessageType) t;\n            }\n        }\n        return null;\n    }\n\n    public MessageType declare(Class type, MessageType parent) {\n        return declare(type, (ClassName) parent.getJavaProtoType(), parent.getProtoFilePath());\n    }","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/annotations-processor/src/main/java/com/netflix/conductor/annotationsprocessor/protogen/types/TypeMapper.java#L64-L100","documentation":"Thrown as IllegalArgumentException by TypeMapper.get(Type) when a Java type cannot be mapped to any proto representation. TypeMapper only knows scalars (int/long/String/bool and boxed forms), registered MessageTypes, List/Set/LinkedList, and Map. Anything else — arrays, custom non-message classes, generic types whose raw type is unsupported — reaches the final guard.","triggerScenarios":"A @ProtoMessage field whose type is an array (int[]), an unsupported collection (e.g. Queue, Iterable), a raw generic whose raw type is not List/Set/Map, or a custom class that was never declared via declare()/addMessageType().","commonSituations":"Adding a new field type protogen does not handle; forgetting to annotate/register a nested message type; using a collection type outside the PROTO_LIST_TYPES set.","solutions":["Replace unsupported collections with List or Set (ArrayList/HashSet/LinkedList are mapped).","Ensure nested message classes are registered via TypeMapper.declare(...) during protogen discovery.","Convert arrays to List<T>.","For a custom type, add it as a @ProtoMessage so it becomes a MessageType before fields referencing it are resolved."],"exampleFix":"// before\n@ProtoMessage public class Job {\n    String[] tags;     // arrays are not mapped\n    Queue<Task> pending; // Queue not in PROTO_LIST_TYPES\n}\n// after\n@ProtoMessage public class Job {\n    List<String> tags;\n    List<Task> pending;\n}","handlingStrategy":"validation","validationCode":"import java.lang.reflect.Field;\nimport java.util.Collection;\nimport java.util.Map;\nstatic void assertMappable(Class<?> msg) {\n    Set<Class<?>> okCollections = Set.of(java.util.List.class, java.util.Set.class,\n        java.util.LinkedList.class, java.util.ArrayList.class, java.util.HashSet.class);\n    for (Field f : msg.getDeclaredFields()) {\n        Class<?> t = f.getType();\n        if (t.isArray()) throw new IllegalStateException(\"Unsupported array field: \" + f);\n        if (Collection.class.isAssignableFrom(t) && !okCollections.contains(t))\n            throw new IllegalStateException(\"Unsupported collection type on \" + f + \": \" + t);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use List/Set (not arrays, Queue, or raw Iterable) for collection fields.","Register all nested message types via declare() before resolving referencing fields.","Add a reflection-based pre-check over @ProtoMessage classes in tests."],"tags":["protogen","protobuf","type-mapping","codegen"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}