apache/beam · error · java.lang.RuntimeException
Could not determine a schema for type
Error message
Could not determine a schema for type
What it means
For an array parameter whose component type is not primitive/wrapper/String, the service tries to resolve a Row schema for the component type to validate payload rows; when getParameterSchema returns null (no valid schema), this error is thrown naming the component class.
Solutions
- Register a schema for the array's component class (@DefaultSchema / SchemaProvider) and redeploy.
- Use a schema-supported component type (POJO with fields, AVRO, Row).
- Verify the expansion service classpath includes the compiled class with schema field registration for the component type.
Example fix
// before
public MyTransform withItems(Item[] items) {...} // Item has no schema
// after
@DefaultSchema(JavaFieldSchema.class)
class Item { public final String id; public Item(String id){this.id=id;} } Defensive patterns
Strategy: validation
Validate before calling
Class<?> comp = paramClass.getComponentType();
try {
Schema s = SchemaRegistry.getDefault().getSchema(comp);
if (s == null || s.getFieldCount() == 0) throw new IllegalStateException("Register a schema for array component " + comp);
} catch (NoSuchSchemaException e) { throw new IllegalStateException("No schema for " + comp, e); } Try / catch
try {
return getTransform(payload);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Could not determine a schema for type")) {
throw new InvalidExpansionRequest("Array component type lacks schema: " + paramClass, e);
}
throw e;
} Prevention
- Annotate array component classes with @DefaultSchema so their schema resolves.
- Keep component types simple POJOs/AVRO/Row rather than arbitrary classes.
- Check row schema assignability (assignableTo) in tests before expansion.
- Deploy the expansion service with classes compiled with schema registration.
When it happens
Trigger: Array parameter of POJO/complex component type whose component class has no registered, non-empty schema in the SchemaRegistry at expansion time.
Common situations: Complex-typed arrays (custom classes) in builder methods where the component class lacks @DefaultSchema registration; stale artifact deployed to the expansion service missing schema metadata.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Could not find a matching method in transform for…
- Expected a schema with a single array field but received
- is not nullable in Array field
- Arrow schema conversion does not support Beam type
- Builder method has to be explicitly allowed
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/73eeca9f67e5bbeb.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java:310
}
// We perform additional validation for arrays and non-primitive types.
if (parameterClass.isArray()) {
Class<?> arrayFieldClass = parameterClass.getComponentType();
if (parameterFromPayload.getType().getTypeName() != TypeName.ARRAY) {
throw new RuntimeException(
"Expected a schema with a single array field but received "
+ parameterFromPayload.getType().getTypeName());
}
// Following is a best-effort validation that may not cover all cases. Idea is to resolve
// ambiguities as much as possible to determine an exact match for the given set of
// parameters. If there are ambiguities, the expansion will fail.
if (!isPrimitiveOrWrapperOrString(arrayFieldClass)) {
@Nullable Collection<Row> values = constructorRow.getArray(i);
Schema arrayFieldSchema = getParameterSchema(arrayFieldClass);
if (arrayFieldSchema == null) {
throw new RuntimeException("Could not determine a schema for type " + arrayFieldClass);
}
if (values != null) {
@Nullable Row firstItem = values.iterator().next();
if (firstItem != null && !firstItem.getSchema().assignableTo(arrayFieldSchema)) {
return false;
}
}
}
} else if (constructorRow.getValue(i) instanceof Row) {
@Nullable Row parameterRow = constructorRow.getRow(i);
Schema schema = getParameterSchema(parameterClass);
if (schema == null) {
throw new RuntimeException("Could not determine a schema for type " + parameterClass);
}
if (parameterRow != null && !parameterRow.getSchema().assignableTo(schema)) {
return false;
}
}View on GitHub (pinned to 12126d8942)