apache/beam · error · RuntimeException

Cound not determine array parameter type for field.

Error message

Cound not determine array parameter type for field.

What it means

Thrown by getMapFieldType when a schema'd field is a Map type but Beam cannot extract exactly two type parameters (key and value) from it. The message text ("Cound not...") contains a known typo. Typically raised when the Map supertype is raw or has fewer than two actual type arguments.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldTypeDescriptors.java:143

    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();
      return FieldType.map(
          fieldTypeForJavaType(TypeDescriptor.of(params[0])),
          fieldTypeForJavaType(TypeDescriptor.of(params[1])));
    }
    throw new RuntimeException("Cound not determine array parameter type for field.");
  }
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Declare the map with both type parameters (e.g. Map<String, Integer>).
  2. For custom map classes, extend Map<K,V> with concrete type arguments.
  3. Use @SchemaCreate or a custom user type if the type cannot be parameterized.

Example fix

// before
private Map lookup;

// after
private Map<String, Double> lookup;
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(td.getType() instanceof java.lang.reflect.ParameterizedType) || ((java.lang.reflect.ParameterizedType) td.getType()).getActualTypeArguments().length != 2) { throw new IllegalStateException("Map field must declare key and value types"); }

Type guard

static boolean isTypedMap(TypeDescriptor<?> td) { return Map.class.isAssignableFrom(td.getRawType()) && td.getType() instanceof java.lang.reflect.ParameterizedType && ((java.lang.reflect.ParameterizedType) td.getType()).getActualTypeArguments().length == 2; }

Try / catch

try { schemaOf(MyBean.class); } catch (RuntimeException e) { if (e.getMessage().startsWith("Cound not determine")) { /* add <K,V> to Map field */ } else { throw e; } }

Prevention

When it happens

Trigger: A field/getter declared as raw Map or a Map subtype without both key and value generics; getMapFieldType fetches getSupertype(Map.class) and params do not yield two usable types.

Common situations: Raw `Map map` in a JavaBean; custom map classes extending raw Map; classes processed by tools that strip 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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/8ba146dcf86a5cac. Report an issue: GitHub.