{"record":{"id":"6f5f887dec99e644","repo":"apache/beam","slug":"could-not-find-a-matching-method-in-transform-for","errorCode":null,"errorMessage":"Could not find a matching method in transform  for BuilderMethod. When using field names, make sure they are available in the compiled Java class.","messagePattern":"Could not find a matching method in transform  for BuilderMethod\\. When using field names, make sure they are available in the compiled Java class\\.","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java","lineNumber":224,"sourceCode":"    return match;\n  }\n\n  private Method getMethod(\n      PTransform<PInput, POutput> transform,\n      BuilderMethod builderMethod,\n      AllowedClass allowListClass) {\n\n    Row builderMethodRow = decodeRow(builderMethod.getSchema(), builderMethod.getPayload());\n\n    List<Method> matchingMethods =\n        Arrays.stream(transform.getClass().getMethods())\n            .filter(m -> isBuilderMethodForName(m, builderMethod.getName(), allowListClass))\n            .filter(m -> parametersCompatible(m.getParameters(), builderMethodRow))\n            .filter(m -> PTransform.class.isAssignableFrom(m.getReturnType()))\n            .collect(Collectors.toList());\n\n    if (matchingMethods.size() == 0) {\n      throw new RuntimeException(\n          \"Could not find a matching method in transform \"\n              + transform\n              + \" for BuilderMethod\"\n              + builderMethod\n              + \". When using field names, make sure they are available in the compiled\"\n              + \" Java class.\");\n    } else if (matchingMethods.size() > 1) {\n      throw new RuntimeException(\n          \"Expected to find exactly one matching method in transform \"\n              + transform\n              + \" for BuilderMethod\"\n              + builderMethod\n              + \" but found \"\n              + matchingMethods.size());\n    }\n    return matchingMethods.get(0);\n  }\n","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java#L206-L242","documentation":"After filtering the transform's methods by name match, parameter compatibility with the payload schema row, and PTransform return type, no method qualified. The service cannot resolve any builder method (or constructor path) matching the requested BuilderMethod in the given transform class.","triggerScenarios":"Expansion payload references a builder method/field name that does not exist on the transform; payload field names not present in the compiled schema of the parameter class (stale compiled class without schema field registration); parameter types incompatible with the supplied row.","commonSituations":"Typos in the method/field name in the payload; transform rebuilt without @DefaultSchema registration so field names are missing from the compiled class; pipeline written against a newer/older transform version than deployed.","solutions":["Correct the BuilderMethod name/field names in the expansion payload to match the transform's actual public builder methods.","Ensure parameter classes have a registered schema (@DefaultSchema / SchemaProvider) so their field names exist in the compiled class.","Align the transform artifact version used by the expansion service with the one the payload was generated from.","Simplify the payload to a single known builder method and add parameters incrementally to find the incompatible one."],"exampleFix":"// before\npayload: {name: \"with_cout\"}\n// after\npayload: {name: \"withCount\"}  // matches existing public builder method","handlingStrategy":"validation","validationCode":"boolean resolvable(Class<?> transform, String methodName, Schema payload) {\n  for (Method m : transform.getMethods()) {\n    if (methodMatchesName(m, methodName) && parametersCompatible(m.getParameters(), payload)\n        && PTransform.class.isAssignableFrom(m.getReturnType())) return true;\n  }\n  return false;\n}","typeGuard":null,"tryCatchPattern":"try {\n  return getTransform(payload);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Could not find a matching method\")) {\n    throw new InvalidExpansionRequest(\"No builder method on \" + transformClass + \" matches \" + payload.getName(), e);\n  }\n  throw e;\n}","preventionTips":["Generate payloads from the same (pinned) transform artifact version used by the expansion service.","Ensure every parameter POJO has schema field registration (@DefaultSchema) so field names exist in the compiled class.","Lint pipeline payloads against the transform's public builder method list in CI.","Avoid relying on the withX field-name convention when exact names are available."],"tags":["java","reflection","schema","beam-expansion-service"],"backgroundTag":"method-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}