apache/beam · error · RuntimeException
Could not determine array parameter type for field.
Error message
Could not determine array parameter type for field.
What it means
Thrown by getArrayFieldType when Beam's schema framework tries to map a Java Collection-typed field to FieldType.array but cannot determine the element type. This happens when the field's type is a Collection subtype whose generic parameter is not available at runtime (e.g. raw type or non-ParameterizedType).
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldTypeDescriptors.java:120
private static FieldType getArrayFieldType(TypeDescriptor typeDescriptor) {
if (typeDescriptor.isArray()) {
if (typeDescriptor.getComponentType().getType().equals(byte.class)) {
return FieldType.BYTES;
} else {
return FieldType.array(fieldTypeForJavaType(typeDescriptor.getComponentType()));
}
}
if (typeDescriptor.isSubtypeOf(TypeDescriptor.of(Collection.class))) {
TypeDescriptor<Collection<?>> collection = typeDescriptor.getSupertype(Collection.class);
if (collection.getType() instanceof ParameterizedType) {
ParameterizedType ptype = (ParameterizedType) collection.getType();
java.lang.reflect.Type[] params = ptype.getActualTypeArguments();
checkArgument(params.length == 1);
return FieldType.array(fieldTypeForJavaType(TypeDescriptor.of(params[0])));
}
}
throw new RuntimeException("Could not determine array parameter type for field.");
}
private static FieldType getIterableFieldType(TypeDescriptor typeDescriptor) {
TypeDescriptor<Iterable<?>> iterable = typeDescriptor.getSupertype(Iterable.class);
if (iterable.getType() instanceof ParameterizedType) {
ParameterizedType ptype = (ParameterizedType) iterable.getType();
java.lang.reflect.Type[] params = ptype.getActualTypeArguments();
checkArgument(params.length == 1);
return FieldType.iterable(fieldTypeForJavaType(TypeDescriptor.of(params[0])));
}
throw new RuntimeException("Could not determine array parameter type for field.");
}
private static FieldType getMapFieldType(TypeDescriptor typeDescriptor) {
TypeDescriptor<Collection<?>> map = typeDescriptor.getSupertype(Map.class);
if (map.getType() instanceof ParameterizedType) {
ParameterizedType ptype = (ParameterizedType) map.getType();
java.lang.reflect.Type[] params = ptype.getActualTypeArguments();View on GitHub (pinned to 12126d8942)
Solutions
- Add explicit type parameters to the collection field (e.g. List<String> instead of raw List).
- If generics genuinely cannot be expressed, register a custom FieldType via @SchemaCreate or a custom Schema user type instead of relying on inference.
- Ensure the class is compiled with generic signature information (not stripped by obfuscation/proguard keep rules).
Example fix
// before private List items; // raw type // after private List<String> items;
Defensive patterns
Strategy: type-guard
Validate before calling
if (field instanceof java.lang.reflect.ParameterizedType) { /* element type available */ } else { throw new IllegalStateException("Field " + field.getName() + " must use a parameterized collection type"); } Type guard
static boolean hasExplicitElementType(java.lang.reflect.Field f) { return f.getGenericType() instanceof java.lang.reflect.ParameterizedType; } Try / catch
try { schemaOf(MyBean.class); } catch (RuntimeException e) { if (e.getMessage().contains("Could not determine array parameter type")) { /* fix raw collection field */ } else { throw e; } } Prevention
- Never use raw collection types in schema'd classes.
- Compile with -Xlint:rawtypes and treat rawtypes warnings as errors.
- Run schema registration in unit tests for all schema'd POJOs.
When it happens
Trigger: Registering a Java class with JavaFieldSchema/JavaBeanSchema where a field or getter is declared as a raw Collection/List (no type parameter), so getActualTypeArguments() yields nothing usable and fieldTypeForJavaType falls through to this throw.
Common situations: Using raw types like `List list` instead of `List<String> list` in a schema'd POJO; type erasure removing generics from wildcard/anonymous types; reflective classes built without generic signatures.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Cound not determine array parameter type for field.
- Was not able to generate getters for schema: {} class: {}
- Unable to generate a creator for POJO '%s' with inferred sch
- Unable to generate a creator for {} with schema {}
- Unable to generate a creator for class {} with schema {}
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8d14378d08645b55.
Report an issue: GitHub.