apache/beam · error · IllegalArgumentException
Unrecognized input type
Error message
Unrecognized input type: ${input} What it means
YamlTransform.expand only knows how to feed an external transform from a PCollection or a PCollectionRowTuple. If the expand() input is any other PValue/PCollection type, the library cannot map it onto the external transform's input and throws IllegalArgumentException naming the object's type.
Solutions
- Convert the input to a PCollection or PCollectionRowTuple before applying the YamlTransform.
- If the input is a PCollectionList, flatten or index it into a single PCollection first.
- Use a standard (non-YAML) transform if you genuinely need exotic input types.
- Check the message's printed object for the concrete class and adjust the pipeline shape accordingly.
Example fix
// before PCollectionList pcs = ...; pipeline.apply(yamlTransform, pcs); // after pcs.get(0).apply(yamlTransform);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(input instanceof PCollection) && !(input instanceof PCollectionRowTuple)) {
throw new IllegalArgumentException("YamlTransform requires PCollection or PCollectionRowTuple, got " + input.getClass());
} Type guard
boolean isYamlTransformInput(PValue v) {
return v instanceof PCollection || v instanceof PCollectionRowTuple;
} Try / catch
try {
return yamlTransform.expand(input);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unrecognized input type")) { /* convert input */ }
throw e;
} Prevention
- Avoid PCollectionList/PCollectionTuple as YAML transform inputs
- Flatten or index multi-PCollections before applying
- Add pipeline-shape unit tests around YAML transform wiring
When it happens
Trigger: Passing a PCollectionList, PCollectionTuple, or other PValue subtype as the input element of a YamlTransform in expand().
Common situations: Building multi-input pipelines where intermediate values are PCollectionList (e.g. from Flatten/Partition outputs) and mistakenly passing them to a YAML transform; refactorings that change input types.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Can't cast non-numeric types: +input
- Can't cast numbers to non-numeric type: +output
- Cannot convert BigQuery type '' to '' because the BigQuery…
- Expected a single PCollection output, but got
- Expected Document but got " + (converted != null ?…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/485f27ff3ac083d2.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/yaml/src/main/java/org/apache/beam/sdk/extensions/yaml/YamlTransform.java:170
}
// There is no generic apply...
POutput output;
@SuppressWarnings("rawtypes")
PTransform externalTransform =
PythonExternalTransform.from("apache_beam.yaml.yaml_transform.YamlTransform")
.withArgs(yamlDefinition)
.withExtraPackages(ImmutableList.of("jinja2", "pyyaml", "virtualenv-clone"));
if (input instanceof PBegin) {
output = ((PBegin) input).apply(externalTransform);
} else if (input instanceof PCollection) {
output = ((PCollection<?>) input).apply(externalTransform);
} else if (input instanceof PCollection) {
output = ((PCollection<?>) input).apply(externalTransform);
} else if (input instanceof PCollectionRowTuple) {
output = ((PCollectionRowTuple) input).apply(externalTransform);
} else {
throw new IllegalArgumentException("Unrecognized input type: " + input);
}
if (outputTags == null) {
if (!(output instanceof PCollection)) {
throw new IllegalArgumentException(
"Expected a single PCollection output, but got "
+ output
+ ". Perhaps withMultipleOutputs() needs to be specified?");
}
return (OutputT) output;
} else {
if (output instanceof PCollection) {
// ExternalPythonTransform always returns single outputs as PCollections.
if (outputTags.size() != 1) {
throw new IllegalArgumentException(
"Expected " + outputTags.size() + " outputs, but got exactly one.");
}
return (OutputT)View on GitHub (pinned to 12126d8942)