{"record":{"id":"0dc270731297bf6c","repo":"apache/beam","slug":"unhandled-input-type-input-getclass","errorCode":null,"errorMessage":"Unhandled input type ${input.getClass()}","messagePattern":"Unhandled input type (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/python/src/main/java/org/apache/beam/sdk/extensions/python/PythonExternalTransform.java","lineNumber":595,"sourceCode":"      ExternalTransforms.ExternalConfigurationPayload payload) {\n    PTransform<PInput, PCollectionTuple> transform =\n        External.of(\n                \"beam:transforms:python:fully_qualified_named\",\n                payload.toByteArray(),\n                expansionService)\n            .withMultiOutputs()\n            .withOutputCoder(this.outputCoders);\n    PCollectionTuple outputs;\n    if (input instanceof PCollection) {\n      outputs = ((PCollection<?>) input).apply(transform);\n    } else if (input instanceof PCollectionTuple) {\n      outputs = ((PCollectionTuple) input).apply(transform);\n    } else if (input instanceof PCollectionRowTuple) {\n      outputs = ((PCollectionRowTuple) input).apply(transform);\n    } else if (input instanceof PBegin) {\n      outputs = ((PBegin) input).apply(transform);\n    } else {\n      throw new RuntimeException(\"Unhandled input type \" + input.getClass());\n    }\n    Set<TupleTag<?>> tags = outputs.getAll().keySet();\n    if (tags.size() == 1) {\n      return (OutputT) outputs.get(Iterables.getOnlyElement(tags));\n    } else {\n      return (OutputT) outputs;\n    }\n  }\n}\n","sourceCodeStart":577,"sourceCodeEnd":605,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/python/src/main/java/org/apache/beam/sdk/extensions/python/PythonExternalTransform.java#L577-L605","documentation":"PythonExternalTransform.apply accepts only PCollection, PCollectionList, PCollectionTuple, PCollectionRowTuple, or PBegin as input. Any other PInput type cannot be wired to the underlying external Python transform, so the library throws RuntimeException naming the unhandled class. This is an internal exhaustiveness guard over supported input types.","triggerScenarios":"Calling apply/expand with a custom or unexpected PInput implementation — e.g. passing a PTransform input wrapper, a null-derived custom collection, or a type from another SDK surface not among the five handled cases.","commonSituations":"Generic pipeline helper methods typed as PInput that pass through arbitrary inputs; custom subclass of PCollection; refactoring that changes the input type without updating the transform application.","solutions":["Convert the input to a supported type (PCollection, PCollectionList, PCollectionTuple, PCollectionRowTuple, or PBegin) before applying the transform","If starting a pipeline, use pipeline.apply(...) with PBegin","Check what concrete type your generic helper actually passes and narrow its signature"],"exampleFix":"// before\nPCollection<String> out = ext.apply(mysteryInput); // RuntimeException\n// after\nPCollection<String> out = pipeline.apply(Create.of(...)).apply(ext);","handlingStrategy":"type-guard","validationCode":"if (!(input instanceof PCollection || input instanceof PCollectionList\n    || input instanceof PCollectionTuple || input instanceof PCollectionRowTuple\n    || input instanceof PBegin)) {\n  throw new IllegalArgumentException(\"Unsupported input type: \" + input.getClass());\n}","typeGuard":"boolean isSupportedInput(org.apache.beam.sdk.values.PInput in) {\n  return in instanceof PCollection || in instanceof PCollectionList\n      || in instanceof PCollectionTuple || in instanceof PCollectionRowTuple\n      || in instanceof PBegin;\n}","tryCatchPattern":"try {\n  result = ext.apply(input);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Unhandled input type\")) {\n    // convert input to a supported PInput type and retry\n  }\n}","preventionTips":["Type helper methods as PCollection/PCollectionTuple instead of raw PInput","Check the concrete input class before applying cross-language transforms","Use PBegin via pipeline.apply when starting a graph"],"tags":["java","beam","type-mismatch","pipeline","unsupported-type"],"backgroundTag":"type-mismatch","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"}