{"record":{"id":"09344fd2a798eccb","repo":"apache/beam","slug":"getter-has-wrong-prefix-method","errorCode":null,"errorMessage":"Getter has wrong prefix <method>","messagePattern":"Getter 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":206,"sourceCode":"    if (fieldDescription == null) {\n      return null;\n    }\n    return fieldDescription.value();\n  }\n\n  public static FieldValueTypeInformation forGetter(Method method, int index) {\n    return forGetter(null, method, index);\n  }\n\n  public static FieldValueTypeInformation forGetter(\n      @Nullable TypeDescriptor<?> typeDescriptor, Method method, int index) {\n    String name;\n    if (method.getName().startsWith(\"get\")) {\n      name = ReflectUtils.stripPrefix(method.getName(), \"get\");\n    } else if (method.getName().startsWith(\"is\")) {\n      name = ReflectUtils.stripPrefix(method.getName(), \"is\");\n    } else {\n      throw new RuntimeException(\"Getter has wrong prefix \" + method.getName());\n    }\n\n    TypeDescriptor<?> type =\n        Optional.ofNullable(typeDescriptor)\n            .map(td -> (TypeDescriptor) td.resolveType(method.getGenericReturnType()))\n            // fall back to previous behavior\n            .orElseGet(() -> TypeDescriptor.of(method.getGenericReturnType()));\n\n    boolean nullable = hasNullableReturnType(method);\n    return new AutoValue_FieldValueTypeInformation.Builder()\n        .setName(getNameOverride(name, method))\n        .setNumber(getNumberOverride(index, method))\n        .setNullable(nullable)\n        .setType(type)\n        .setRawType(type.getRawType())\n        .setMethod(method)\n        .setElementType(getIterableComponentType(type))\n        .setMapKeyType(getMapKeyType(type))","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldValueTypeInformation.java#L188-L224","documentation":"Thrown by FieldValueTypeInformation.forGetter when a method is being introspected as a getter but its name does not start with the recognized prefixes \"get\" or \"is\". The schema framework only accepts JavaBean-style getters, so any other method passed as a getter fails.","triggerScenarios":"Passing a method whose name lacks the get/is prefix to forGetter; schema discovery routing a non-getter method (e.g. calculateTotal or fetchName) into getter handling.","commonSituations":"Custom getter prefixes (e.g. `fetch`, `retrieve`) in bean-like classes; fluent-style getters returning this without prefix; methods inherited from interfaces that don't follow JavaBean conventions.","solutions":["Rename the method to start with get (or is for boolean return types).","If the method is not a field getter, exclude it from schema introspection (e.g. make it private or annotate the class schema accordingly).","Use @SchemaFieldName on a properly-prefixed getter to control the schema field name instead of custom prefixes."],"exampleFix":"// before\npublic String fetchName() { ... }\n\n// after\npublic String getName() { ... }","handlingStrategy":"validation","validationCode":"for (Method m : clazz.getMethods()) { if (m.getParameterCount() == 0 && !m.getName().startsWith(\"get\") && !m.getName().startsWith(\"is\") && !java.lang.reflect.Modifier.isStatic(m.getModifiers())) { /* exclude or rename before registering */ } }","typeGuard":"static boolean isBeanGetter(Method m) { return m.getParameterCount() == 0 && (m.getName().startsWith(\"get\") || m.getName().startsWith(\"is\")) && !m.getReturnType().equals(void.class); }","tryCatchPattern":"try { schemaOf(clazz); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Getter has wrong prefix\")) { /* rename method or exclude from schema */ } else { throw e; } }","preventionTips":["Follow strict JavaBean getter naming (getX/isX for boolean).","Avoid custom getter prefixes in schema'd classes.","Keep non-property helper methods private or static."],"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"}