{"record":{"id":"5c3c70eafa024035","repo":"apache/beam","slug":"setter-has-wrong-prefix-method","errorCode":null,"errorMessage":"Setter has wrong prefix <method>","messagePattern":"Setter has wrong prefix <method>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldValueTypeInformation.java","lineNumber":291,"sourceCode":"    return forSetter(null, method);\n  }\n\n  public static FieldValueTypeInformation forSetter(Method method, String setterPrefix) {\n    return forSetter(null, method, setterPrefix);\n  }\n\n  public static FieldValueTypeInformation forSetter(\n      @Nullable TypeDescriptor<?> typeDescriptor, Method method) {\n    return forSetter(typeDescriptor, method, \"set\");\n  }\n\n  public static FieldValueTypeInformation forSetter(\n      @Nullable TypeDescriptor<?> typeDescriptor, Method method, String setterPrefix) {\n    String name;\n    if (method.getName().startsWith(setterPrefix)) {\n      name = ReflectUtils.stripPrefix(method.getName(), setterPrefix);\n    } else {\n      throw new RuntimeException(\"Setter has wrong prefix \" + method.getName());\n    }\n\n    TypeDescriptor<?> type =\n        Optional.ofNullable(typeDescriptor)\n            .map(td -> (TypeDescriptor) td.resolveType(method.getGenericParameterTypes()[0]))\n            // fall back to previous behavior\n            .orElseGet(() -> TypeDescriptor.of(method.getGenericParameterTypes()[0]));\n    boolean nullable = hasSingleNullableParameter(method);\n    return new AutoValue_FieldValueTypeInformation.Builder()\n        .setName(name)\n        .setNullable(nullable)\n        .setType(type)\n        .setRawType(type.getRawType())\n        .setMethod(method)\n        .setElementType(getIterableComponentType(type))\n        .setMapKeyType(getMapKeyType(type))\n        .setMapValueType(getMapValueType(type))\n        .setOneOfTypes(Collections.emptyMap())","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldValueTypeInformation.java#L273-L309","documentation":"Thrown by FieldValueTypeInformation.forSetter when a method expected to be a setter does not start with the configured setterPrefix (default \"set\"). The prefix is stripped to derive the property name, so a mismatching name cannot be mapped.","triggerScenarios":"Schema registration with a custom setter prefix (e.g. \"with\") while methods use \"set\", or vice versa; passing a non-setter method to forSetter.","commonSituations":"Builder-style classes using withX/prefix conventions being registered with default \"set\" prefix; custom setterPrefix string mismatch (case or trailing characters).","solutions":["Rename the method to start with the setterPrefix in use (default \"set\").","Pass the correct setterPrefix to JavaBeanSchema/forSetter to match the class convention (e.g. \"with\" for builders).","Use @SchemaFieldName-style annotations on getters and let mapping match setters by property name."],"exampleFix":"// before (schema uses \"set\" prefix)\npublic User withName(String name) { ... }\n\n// after\npublic User setName(String name) { ... }","handlingStrategy":"validation","validationCode":"String prefix = \"set\"; for (Method m : clazz.getMethods()) { if (m.getParameterCount() == 1 && !m.getName().startsWith(prefix)) { /* flag non-setter single-arg methods or fix prefix */ } }","typeGuard":"static boolean matchesSetterPrefix(Method m, String prefix) { return m.getName().startsWith(prefix) && m.getParameterCount() == 1; }","tryCatchPattern":"try { schemaOf(clazz); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Setter has wrong prefix\")) { /* align method names with setterPrefix */ } else { throw e; } }","preventionTips":["Use the standard \"set\" prefix unless intentionally configuring a custom setterPrefix.","Ensure custom setterPrefix strings match method names exactly (case included).","Avoid mixing builder-style withX and setX in the same schema'd class."],"tags":["java","javabeans","beam-schema","naming-convention"],"backgroundTag":"invalid-argument-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}