{"record":{"id":"1ffeda4019776ca9","repo":"apache/beam","slug":"found-setters-marked-with-s","errorCode":null,"errorMessage":"Found setters marked with @%s:","messagePattern":"Found setters marked with @(.+?):","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java","lineNumber":1458,"sourceCode":"      throw new IllegalArgumentException(\n          String.format(\n              \"Expected setter for property [%s] to not be marked with @%s on %s\",\n              setter.descriptor.getName(),\n              annotationClass.getSimpleName(),\n              setter.settersWithTheAnnotationClassNames));\n    } else if (setters.size() > 1) {\n      StringBuilder builder =\n          new StringBuilder(\n              String.format(\"Found setters marked with @%s:\", annotationClass.getSimpleName()));\n      for (AnnotatedSetter setter : setters) {\n        builder.append(\n            String.format(\n                \"%n  - Setter for property [%s] should not be marked with @%s on %s\",\n                setter.descriptor.getName(),\n                annotationClass.getSimpleName(),\n                setter.settersWithTheAnnotationClassNames));\n      }\n      throw new IllegalArgumentException(builder.toString());\n    }\n  }\n\n  private static class MissingBeanMethod {\n    String methodType;\n    PropertyDescriptor property;\n  }\n\n  private static void throwForMissingBeanMethod(\n      Class<? extends PipelineOptions> iface, List<MissingBeanMethod> missingBeanMethods) {\n    if (missingBeanMethods.size() == 1) {\n      MissingBeanMethod missingBeanMethod = missingBeanMethods.get(0);\n      throw new IllegalArgumentException(\n          String.format(\n              \"Expected %s for property [%s] of type [%s] on [%s].\",\n              missingBeanMethod.methodType,\n              missingBeanMethod.property.getName(),\n              missingBeanMethod.property.getPropertyType().getName(),","sourceCodeStart":1440,"sourceCodeEnd":1476,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java#L1440-L1476","documentation":"The aggregated variant of the annotated-setter error: when several setters are wrongly marked with a getter-only annotation, Beam throws one message 'Found setters marked with @%s:' followed by a line per offending setter, then fails options registration.","triggerScenarios":"PipelineOptionsFactory registration when throwForSettersWithTheAnnotation receives setters.size() > 1; the builder appends '%n - Setter for property [...] should not be marked with @%s on [...]' for each before throwing.","commonSituations":"Generating accessors with a tool/template that copies annotations to setters; large options interfaces where many setters were annotated during a bulk edit.","solutions":["Strip the named annotation from every setter listed in the message.","Verify the annotation exists on the corresponding getters.","Add a lint/checkstyle rule or unit test that calls PipelineOptionsFactory.as() on all option interfaces in CI to catch this early."],"exampleFix":"// before\n@Default.Integer(1) int getFoo();\n@Default.Integer(1) void setFoo(int v);\n@Default.String(\"s\") String getBar();\n@Default.String(\"s\") void setBar(String v);\n// after\n@Default.Integer(1) int getFoo();\nvoid setFoo(int v);\n@Default.String(\"s\") String getBar();\nvoid setBar(String v);","handlingStrategy":"validation","validationCode":"java.util.List<java.lang.reflect.Method> bad = new java.util.ArrayList<>();\nfor (java.lang.reflect.Method m : MyOptions.class.getMethods()) {\n  if (m.getName().startsWith(\"set\") && m.getAnnotations().length > 0) bad.add(m);\n}\nif (!bad.isEmpty()) System.err.println(\"Setters with getter-only annotations: \" + bad);","typeGuard":null,"tryCatchPattern":"try {\n  PipelineOptionsFactory.fromArgs(args).as(MyOptions.class);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Found setters marked with @\")) { /* strip annotations from every listed setter */ }\n  throw e;\n}","preventionTips":["Fix every setter listed in the aggregated message before re-running","Add an ArchUnit/checkstyle test banning annotations on set* methods","Run options validation in CI for all option interfaces"],"tags":["java","apache-beam","pipeline-options","annotation-target"],"backgroundTag":"invalid-argument-value","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"}