apache/beam · error · java.lang.IllegalArgumentException

The configuration class

Error message

The configuration class %s is missing a setter %s for %s with type %s

What it means

Thrown by ExpansionService.payloadToConfigSetters when reflective lookup of a setter method on the configuration class fails. For each schema field the service computes the JavaBean setter name ('set' + capitalized field name) and calls getClass().getMethod(setterName, type); if no such public setter exists the mapping from Row to config object cannot proceed.

Solutions

  1. Add the missing public setter to the configuration class, named set<Field> with exactly the type shown in the message.
  2. Rename the schema field (or add a SchemaCreate/SchemaFieldGetterAndSetter compatible accessor) so it matches an existing setter.
  3. Verify the field's type in the schema matches the setter's parameter type (e.g. int vs long vs String).

Example fix

// before
class MyConfig { public final String pattern; MyConfig(String p) { pattern = p; } }
// after
class MyConfig {
  private String pattern;
  public String getPattern() { return pattern; }
  public void setPattern(String pattern) { this.pattern = pattern; }
}
Defensive patterns

Strategy: validation

Validate before calling

for (Schema.Field f : schema.getFields()) {
  String setter = "set" + Character.toUpperCase(f.getName().charAt(0)) + f.getName().substring(1);
  if (Arrays.stream(MyConfig.class.getMethods()).noneMatch(m -> m.getName().equals(setter) && m.getParameterCount() == 1)) {
    throw new IllegalStateException("Missing setter: " + setter);
  }
}

Try / catch

try {
  Row configRow = /* decode payload */;
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("is missing a setter")) { /* fix config class accessors */ }
  throw e;
}

Prevention

When it happens

Trigger: Expanding a transform whose configuration class lacks a public setter matching a schema field — e.g. field 'numShards' requires setNumShards(int) but the class only has a builder, a final field, or a setter with a different parameter type.

Common situations: Config class written with immutable/builder style instead of JavaBean getters+setters; schema field name doesn't match the Java property naming convention; setter exists but takes a boxed/primitive type different from the coder's encoded type.

Related errors


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

Appendix: source

Thrown at sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/ExpansionService.java:512

    ConfigT config = constructor.newInstance();
    for (Field field : configRow.getSchema().getFields()) {
      String key = field.getName();
      @Nullable Object value = configRow.getValue(field.getName());

      String fieldName = key;

      Coder coder = SchemaCoder.coderForFieldType(field.getType());
      Class type = coder.getEncodedTypeDescriptor().getRawType();

      String setterName =
          "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
      Method method;
      try {
        // retrieve the setter for this field
        method = config.getClass().getMethod(setterName, type);
      } catch (NoSuchMethodException e) {
        throw new IllegalArgumentException(
            String.format(
                "The configuration class %s is missing a setter %s for %s with type %s",
                config.getClass(),
                setterName,
                fieldName,
                coder.getEncodedTypeDescriptor().getType().getTypeName()),
            e);
      }
      invokeSetter(config, value, method);
    }
    return config;
  }

  // Checker framework is conservative for Method#invoke, args are NonNull
  // See https://checkerframework.org/manual/#reflection-resolution
  @SuppressWarnings("nullness")
  private static <ConfigT> void invokeSetter(ConfigT config, @Nullable Object value, Method method)
      throws IllegalAccessException, InvocationTargetException {

View on GitHub (pinned to 12126d8942)