{"record":{"id":"833ccfb8cf529cce","repo":"apache/beam","slug":"type-mismatches-between-getters-and-setters-detected","errorCode":null,"errorMessage":"Type mismatches between getters and setters detected:","messagePattern":"Type mismatches between getters and setters detected:","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java","lineNumber":937,"sourceCode":"    if (mismatches.size() == 1) {\n      TypeMismatch mismatch = mismatches.get(0);\n      throw new IllegalArgumentException(\n          String.format(\n              \"Type mismatch between getter and setter methods for property [%s]. \"\n                  + \"Getter is of type [%s] whereas setter is of type [%s].\",\n              mismatch.propertyName, mismatch.getterPropertyType, mismatch.setterPropertyType));\n    } else if (mismatches.size() > 1) {\n      StringBuilder builder =\n          new StringBuilder(\"Type mismatches between getters and setters detected:\");\n      for (TypeMismatch mismatch : mismatches) {\n        builder.append(\n            String.format(\n                \"%n  - Property [%s]: Getter is of type [%s] whereas setter is of type [%s].\",\n                mismatch.propertyName,\n                mismatch.getterPropertyType.toString(),\n                mismatch.setterPropertyType.toString()));\n      }\n      throw new IllegalArgumentException(builder.toString());\n    }\n  }\n\n  /**\n   * Returns a map of required groups of arguments to the properties that satisfy the requirement.\n   */\n  private static SortedSetMultimap<String, String> getRequiredGroupNamesToProperties(\n      Map<String, Method> propertyNamesToGetters) {\n    SortedSetMultimap<String, String> result = TreeMultimap.create();\n    for (Map.Entry<String, Method> propertyEntry : propertyNamesToGetters.entrySet()) {\n      Required requiredAnnotation =\n          propertyEntry.getValue().getAnnotation(Validation.Required.class);\n      if (requiredAnnotation != null) {\n        for (String groupName : requiredAnnotation.groups()) {\n          result.put(groupName, propertyEntry.getKey());\n        }\n      }\n    }","sourceCodeStart":919,"sourceCodeEnd":955,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java#L919-L955","documentation":"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.","triggerScenarios":"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).","commonSituations":"Large options interfaces refactored with inconsistent types, migration where several option types changed at once, or third-party options plugin interfaces violating the contract.","solutions":["Read each listed property in the message and align its setter parameter type with its getter return type.","Fix all listed mismatches — the factory throws for the aggregate list, so resolving one won't clear the error until all match.","Use the IDE to regenerate setters for all properties on the offending interfaces.","Run a compile-time check or test that calls PipelineOptionsFactory.fromArgs on the interfaces early in CI."],"exampleFix":"// before\nint getNumShards();\nvoid setNumShards(String n);\nlong getTimeout();\nvoid setTimeout(Duration d);\n// after\nint getNumShards();\nvoid setNumShards(int n);\nlong getTimeout();\nvoid setTimeout(long d);","handlingStrategy":"validation","validationCode":"for (Class<? extends PipelineOptions> o : registered) PipelineOptionsFactory.as(o); // throws listing all mismatches","typeGuard":null,"tryCatchPattern":"try { PipelineOptionsFactory.fromArgs(args).as(MyOptions.class); } catch (IllegalArgumentException e) { LOG.error(e.getMessage()); throw e; }","preventionTips":["Fix every property listed in the message, not just the first","Keep a CI test validating all options interfaces with PipelineOptionsFactory","Standardize option types on importable primitives/POJOs to avoid drift"],"tags":["apache-beam","type-mismatch","options-interface"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}