{"record":{"id":"8d14378d08645b55","repo":"apache/beam","slug":"could-not-determine-array-parameter-type-for-field","errorCode":null,"errorMessage":"Could not determine array parameter type for field.","messagePattern":"Could not determine array parameter type for field\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldTypeDescriptors.java","lineNumber":120,"sourceCode":"\n  private static FieldType getArrayFieldType(TypeDescriptor typeDescriptor) {\n    if (typeDescriptor.isArray()) {\n      if (typeDescriptor.getComponentType().getType().equals(byte.class)) {\n        return FieldType.BYTES;\n      } else {\n        return FieldType.array(fieldTypeForJavaType(typeDescriptor.getComponentType()));\n      }\n    }\n    if (typeDescriptor.isSubtypeOf(TypeDescriptor.of(Collection.class))) {\n      TypeDescriptor<Collection<?>> collection = typeDescriptor.getSupertype(Collection.class);\n      if (collection.getType() instanceof ParameterizedType) {\n        ParameterizedType ptype = (ParameterizedType) collection.getType();\n        java.lang.reflect.Type[] params = ptype.getActualTypeArguments();\n        checkArgument(params.length == 1);\n        return FieldType.array(fieldTypeForJavaType(TypeDescriptor.of(params[0])));\n      }\n    }\n    throw new RuntimeException(\"Could not determine array parameter type for field.\");\n  }\n\n  private static FieldType getIterableFieldType(TypeDescriptor typeDescriptor) {\n    TypeDescriptor<Iterable<?>> iterable = typeDescriptor.getSupertype(Iterable.class);\n    if (iterable.getType() instanceof ParameterizedType) {\n      ParameterizedType ptype = (ParameterizedType) iterable.getType();\n      java.lang.reflect.Type[] params = ptype.getActualTypeArguments();\n      checkArgument(params.length == 1);\n      return FieldType.iterable(fieldTypeForJavaType(TypeDescriptor.of(params[0])));\n    }\n    throw new RuntimeException(\"Could not determine array parameter type for field.\");\n  }\n\n  private static FieldType getMapFieldType(TypeDescriptor typeDescriptor) {\n    TypeDescriptor<Collection<?>> map = typeDescriptor.getSupertype(Map.class);\n    if (map.getType() instanceof ParameterizedType) {\n      ParameterizedType ptype = (ParameterizedType) map.getType();\n      java.lang.reflect.Type[] params = ptype.getActualTypeArguments();","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldTypeDescriptors.java#L102-L138","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nprivate List items; // raw type\n\n// after\nprivate List<String> items;","handlingStrategy":"type-guard","validationCode":"if (field instanceof java.lang.reflect.ParameterizedType) { /* element type available */ } else { throw new IllegalStateException(\"Field \" + field.getName() + \" must use a parameterized collection type\"); }","typeGuard":"static boolean hasExplicitElementType(java.lang.reflect.Field f) { return f.getGenericType() instanceof java.lang.reflect.ParameterizedType; }","tryCatchPattern":"try { schemaOf(MyBean.class); } catch (RuntimeException e) { if (e.getMessage().contains(\"Could not determine array parameter type\")) { /* fix raw collection field */ } else { throw e; } }","preventionTips":["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."],"tags":["java","beam-schema","type-erasure","reflection"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}