{"record":{"id":"ec47ccb7aaf04213","repo":"apache/beam","slug":"could-not-invoke-the-builder-method-on-transform-with","errorCode":null,"errorMessage":"Could not invoke the builder method  on transform  with parameter schema ","messagePattern":"Could not invoke the builder method  on transform  with parameter schema ","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java","lineNumber":159,"sourceCode":"  @SuppressWarnings(\"assignment\")\n  private PTransform<PInput, POutput> applyBuilderMethods(\n      PTransform<PInput, POutput> transform,\n      JavaClassLookupPayload payload,\n      AllowedClass allowListClass) {\n    for (BuilderMethod builderMethod : payload.getBuilderMethodsList()) {\n      Method method = getMethod(transform, builderMethod, allowListClass);\n      try {\n        Row builderMethodRow = decodeRow(builderMethod.getSchema(), builderMethod.getPayload());\n        transform =\n            (PTransform<PInput, POutput>)\n                method.invoke(\n                    transform,\n                    getParameterValues(\n                        method.getParameters(),\n                        builderMethodRow,\n                        method.getGenericParameterTypes()));\n      } catch (IllegalAccessException | InvocationTargetException e) {\n        throw new IllegalArgumentException(\n            \"Could not invoke the builder method \"\n                + builderMethod\n                + \" on transform \"\n                + transform\n                + \" with parameter schema \"\n                + builderMethod.getSchema(),\n            e);\n      }\n    }\n\n    return transform;\n  }\n\n  private boolean isBuilderMethodForName(\n      Method method, String nameFromPayload, AllowedClass allowListClass) {\n    // Lookup based on method annotations\n    for (Annotation annotation : method.getAnnotations()) {\n      if (annotation instanceof MultiLanguageBuilderMethod) {","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java#L141-L177","documentation":"The transform class was instantiated, but invoking the selected builder method reflectively failed with IllegalAccessException or InvocationTargetException. The service wraps this in IllegalArgumentException, naming the builder method, the transform, and the schema of the parameters.","triggerScenarios":"Calling ExpansionService expand where the resolved builder method (e.g. a 'withX' method or @MultiLanguageBuilderMethod) throws an exception during invocation, or is not accessible from the expansion service (non-public class/method).","commonSituations":"Builder method validates its arguments and throws (bad values supplied via the schema payload); method lives in a package-private class; version skew between payload schema and deployed transform so an internal call fails.","solutions":["Read the InvocationTargetException's cause ('Caused by') and fix the invalid input that made the builder throw.","Make the transform class and the builder method public so reflection can invoke them.","Verify the parameter schema in the expansion request matches what the builder method expects for the deployed version.","Rebuild/redeploy the expansion service with the same transform version your pipeline payload targets."],"exampleFix":"// before\n// package-private builder throwing on bad value\nMyTransform withCount(int n) { if (n < 0) throw new IllegalArgumentException(); ... }\n// after\npublic MyTransform withCount(int n) { /* accept validated n */ ... }","handlingStrategy":"try-catch","validationCode":"// validate builder inputs against the method schema before expansion\nMethod m = resolveBuilderMethod(transformClass, builderName);\nfor (Parameter p : m.getParameters()) {\n  if (!schemaCompatible(p, builderMethodRow)) throw new IllegalArgumentException(\"Bad value for \" + p.getName());\n}","typeGuard":"function builderAccessible(transform) {\n  return java.lang.reflect.Modifier.isPublic(transform.getClass().getModifiers());\n}","tryCatchPattern":"try {\n  return applyBuilderMethods(transform, method, row);\n} catch (IllegalArgumentException e) {\n  Throwable cause = e.getCause();\n  if (cause instanceof InvocationTargetException) {\n    log.error(\"Builder {} threw: {}\", method, cause.getCause(), cause); // fix the invalid input reported by the builder\n  }\n  throw e;\n}","preventionTips":["Keep builder methods simple validators/setters; defer heavy work to expand(), not the builder.","Make transform classes and builder methods public.","Test each builder method locally with representative payload rows before exposing via expansion.","Keep payload parameter schema in sync with the deployed transform version."],"tags":["java","reflection","beam-expansion-service"],"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"}