apache/beam · error · IllegalArgumentException

Type mismatches between getters and setters detected:

Error message

Type mismatches between getters and setters detected:

What it means

When PipelineOptionsFactory finds more than one PipelineOptions property whose getter and setter types disagree, it aggregates all of them into a single IllegalArgumentException whose message begins 'Type mismatches between getters and setters detected:' followed by one line per property.

Solutions

  1. Read each listed property in the message and align its setter parameter type with its getter return type.
  2. Fix all listed mismatches — the factory throws for the aggregate list, so resolving one won't clear the error until all match.
  3. Use the IDE to regenerate setters for all properties on the offending interfaces.
  4. Run a compile-time check or test that calls PipelineOptionsFactory.fromArgs on the interfaces early in CI.

Example fix

// before
int getNumShards();
void setNumShards(String n);
long getTimeout();
void setTimeout(Duration d);
// after
int getNumShards();
void setNumShards(int n);
long getTimeout();
void setTimeout(long d);
Defensive patterns

Strategy: validation

Validate before calling

for (Class<? extends PipelineOptions> o : registered) PipelineOptionsFactory.as(o); // throws listing all mismatches

Try / catch

try { PipelineOptionsFactory.fromArgs(args).as(MyOptions.class); } catch (IllegalArgumentException e) { LOG.error(e.getMessage()); throw e; }

Prevention

When it happens

Trigger: Registering/validating PipelineOptions interfaces where two or more properties have type-mismatched getter/setter pairs (e.g. via PipelineOptionsFactory.as() or Pipeline.create() scanning registered options).

Common situations: Large options interfaces refactored with inconsistent types, migration where several option types changed at once, or third-party options plugin interfaces violating the contract.

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/833ccfb8cf529cce. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java:937

    if (mismatches.size() == 1) {
      TypeMismatch mismatch = mismatches.get(0);
      throw new IllegalArgumentException(
          String.format(
              "Type mismatch between getter and setter methods for property [%s]. "
                  + "Getter is of type [%s] whereas setter is of type [%s].",
              mismatch.propertyName, mismatch.getterPropertyType, mismatch.setterPropertyType));
    } else if (mismatches.size() > 1) {
      StringBuilder builder =
          new StringBuilder("Type mismatches between getters and setters detected:");
      for (TypeMismatch mismatch : mismatches) {
        builder.append(
            String.format(
                "%n  - Property [%s]: Getter is of type [%s] whereas setter is of type [%s].",
                mismatch.propertyName,
                mismatch.getterPropertyType.toString(),
                mismatch.setterPropertyType.toString()));
      }
      throw new IllegalArgumentException(builder.toString());
    }
  }

  /**
   * Returns a map of required groups of arguments to the properties that satisfy the requirement.
   */
  private static SortedSetMultimap<String, String> getRequiredGroupNamesToProperties(
      Map<String, Method> propertyNamesToGetters) {
    SortedSetMultimap<String, String> result = TreeMultimap.create();
    for (Map.Entry<String, Method> propertyEntry : propertyNamesToGetters.entrySet()) {
      Required requiredAnnotation =
          propertyEntry.getValue().getAnnotation(Validation.Required.class);
      if (requiredAnnotation != null) {
        for (String groupName : requiredAnnotation.groups()) {
          result.put(groupName, propertyEntry.getKey());
        }
      }
    }

View on GitHub (pinned to 12126d8942)