conductor-oss/conductor · error · IllegalArgumentException

Cannot map type:

Error message

Cannot map type: 

What it means

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.

Source

Thrown at annotations-processor/src/main/java/com/netflix/conductor/annotationsprocessor/protogen/types/TypeMapper.java:82

                        Any.class,
                        ClassName.get(Any.class),
                        "google.protobuf.Any",
                        "google/protobuf/any.proto"));
    }

    public AbstractType get(Type t) {
        if (!types.containsKey(t)) {
            if (t instanceof ParameterizedType) {
                Type raw = ((ParameterizedType) t).getRawType();
                if (PROTO_LIST_TYPES.containsKey(raw)) {
                    types.put(t, new ListType(t));
                } else if (raw.equals(Map.class)) {
                    types.put(t, new MapType(t));
                }
            }
        }
        if (!types.containsKey(t)) {
            throw new IllegalArgumentException("Cannot map type: " + t);
        }
        return types.get(t);
    }

    public MessageType get(String className) {
        for (Map.Entry<Type, AbstractType> pair : types.entrySet()) {
            AbstractType t = pair.getValue();
            if (t instanceof MessageType) {
                if (((Class) t.getJavaType()).getSimpleName().equals(className))
                    return (MessageType) t;
            }
        }
        return null;
    }

    public MessageType declare(Class type, MessageType parent) {
        return declare(type, (ClassName) parent.getJavaProtoType(), parent.getProtoFilePath());
    }

View on GitHub (pinned to cf7c3e4a8a)

Solutions

  1. Replace unsupported collections with List or Set (ArrayList/HashSet/LinkedList are mapped).
  2. Ensure nested message classes are registered via TypeMapper.declare(...) during protogen discovery.
  3. Convert arrays to List<T>.
  4. For a custom type, add it as a @ProtoMessage so it becomes a MessageType before fields referencing it are resolved.

Example fix

// before
@ProtoMessage public class Job {
    String[] tags;     // arrays are not mapped
    Queue<Task> pending; // Queue not in PROTO_LIST_TYPES
}
// after
@ProtoMessage public class Job {
    List<String> tags;
    List<Task> pending;
}
Defensive patterns

Strategy: validation

Validate before calling

import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Map;
static void assertMappable(Class<?> msg) {
    Set<Class<?>> okCollections = Set.of(java.util.List.class, java.util.Set.class,
        java.util.LinkedList.class, java.util.ArrayList.class, java.util.HashSet.class);
    for (Field f : msg.getDeclaredFields()) {
        Class<?> t = f.getType();
        if (t.isArray()) throw new IllegalStateException("Unsupported array field: " + f);
        if (Collection.class.isAssignableFrom(t) && !okCollections.contains(t))
            throw new IllegalStateException("Unsupported collection type on " + f + ": " + t);
    }
}

Prevention

When it happens

Trigger: 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().

Common situations: 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.

Related errors


AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14). Data as JSON: /api/errors/c3ac8aa3d275eb72. Report an issue: GitHub.