{"record":{"id":"954dcaf1ea18910a","repo":"apache/beam","slug":"unable-to-generate","errorCode":null,"errorMessage":"Unable to generate","messagePattern":"Unable to generate","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/SelectByteBuddyHelpers.java","lineNumber":191,"sourceCode":"                  FieldManifestation.FINAL)\n              .defineConstructor(Modifier.PUBLIC)\n              .withParameters(Schema.class)\n              .intercept(new SelectInstructionConstructor());\n\n      return builder\n          .visit(new AsmVisitorWrapper.ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES))\n          .make()\n          .load(\n              ReflectHelpers.findClassLoader(Row.class.getClassLoader()),\n              getClassLoadingStrategy(RowSelector.class))\n          .getLoaded()\n          .getDeclaredConstructor(Schema.class)\n          .newInstance(outputSchema);\n    } catch (InstantiationException\n        | IllegalAccessException\n        | NoSuchMethodException\n        | InvocationTargetException e) {\n      throw new RuntimeException(\"Unable to generate\");\n    }\n  }\n\n  private static class SelectInstructionConstructor implements Implementation {\n    @Override\n    public InstrumentedType prepare(InstrumentedType instrumentedType) {\n      return instrumentedType;\n    }\n\n    @Override\n    public ByteCodeAppender appender(final Target implementationTarget) {\n      return (methodVisitor, implementationContext, instrumentedMethod) -> {\n        int numLocals = 1 + instrumentedMethod.getParameters().size();\n        StackManipulation stackManipulation =\n            new StackManipulation.Compound(\n                // Call the base constructor for Object.\n                MethodVariableAccess.loadThis(),\n                Duplication.SINGLE,","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/SelectByteBuddyHelpers.java#L173-L209","documentation":"createRowSelector uses ByteBuddy to dynamically generate a row-selector class, then reflectively instantiates it via the generated class's (Schema) constructor. If class generation/instantiation fails for any reason (InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException), the original cause is discarded and replaced with this bare RuntimeException(\"Unable to generate\"), which hides the root cause.","triggerScenarios":"Calling SelectByteBuddyHelpers.createRowSelector (via SelectHelpers.createRowSelector) on a schema/type whose generated selector class cannot be instantiated: the generated class lacks the expected Schema constructor, the constructor throws during init, or the type is inaccessible to the generated class.","commonSituations":"Running under restrictive classloaders or SecurityManager, shading/relocation breaking ByteBuddy helper classes, exotic or non-instantiable schema element types, or Beam version changes to the generated-class contract.","solutions":["Inspect the suppressed/underlying cause by reproducing with a debugger or by checking the classloader/shading setup; the bare message hides the real exception.","Ensure ByteBuddy-generated classes are not stripped or relocated incorrectly by shading plugins (keep org.apache.beam.sdk.schemas.utils bytebuddy helper classes).","Verify the JVM has no SecurityManager/restriction blocking reflection and defineClass for generated classes.","Upgrade/downgrade Beam to a version where schema selector generation matches your runtime (check release notes for schemas/ByteBuddy changes).","As a fallback, use the non-bytecode selector path (e.g. JavaBeanSolver-based reflection selector) by configuring the selector factory if available."],"exampleFix":"// before\nRow row = rowWithSelect.apply(Select.fieldNames(\"a.b.c\")); // throws Unable to generate under shaded jar\n// after\n// keep ByteBuddy classes in shade plugin:\n// <relocations><relocation><pattern>net.bytebuddy</pattern>... exclude sdk schemas helpers\nRow row = rowWithSelect.apply(Select.fieldNames(\"a.b.c\"));","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  Selector sel = SelectHelpers.createRowSelector(schema, outputSchema, pathPrefix);\n} catch (RuntimeException e) {\n  // message is 'Unable to generate' with cause swallowed; log schema + classloader info\n  logger.warning(\"Row selector generation failed for schema \" + outputSchema + \": \" + e);\n  throw new IllegalStateException(\"selector generation failed\", e);\n}","preventionTips":["Avoid shading/relocating ByteBuddy classes used by Beam schemas","Test schema selects early in CI on the target runtime/classloader","Keep Beam versions consistent across pipeline authoring and execution"],"tags":["java","reflection","bytebuddy","schema","codegen"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}