{"record":{"id":"73eeca9f67e5bbeb","repo":"apache/beam","slug":"could-not-determine-a-schema-for-type","errorCode":null,"errorMessage":"Could not determine a schema for type ","messagePattern":"Could not determine a schema for type ","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java","lineNumber":310,"sourceCode":"      }\n\n      // We perform additional validation for arrays and non-primitive types.\n      if (parameterClass.isArray()) {\n        Class<?> arrayFieldClass = parameterClass.getComponentType();\n        if (parameterFromPayload.getType().getTypeName() != TypeName.ARRAY) {\n          throw new RuntimeException(\n              \"Expected a schema with a single array field but received \"\n                  + parameterFromPayload.getType().getTypeName());\n        }\n\n        // Following is a best-effort validation that may not cover all cases. Idea is to resolve\n        // ambiguities as much as possible to determine an exact match for the given set of\n        // parameters. If there are ambiguities, the expansion will fail.\n        if (!isPrimitiveOrWrapperOrString(arrayFieldClass)) {\n          @Nullable Collection<Row> values = constructorRow.getArray(i);\n          Schema arrayFieldSchema = getParameterSchema(arrayFieldClass);\n          if (arrayFieldSchema == null) {\n            throw new RuntimeException(\"Could not determine a schema for type \" + arrayFieldClass);\n          }\n          if (values != null) {\n            @Nullable Row firstItem = values.iterator().next();\n            if (firstItem != null && !firstItem.getSchema().assignableTo(arrayFieldSchema)) {\n              return false;\n            }\n          }\n        }\n      } else if (constructorRow.getValue(i) instanceof Row) {\n        @Nullable Row parameterRow = constructorRow.getRow(i);\n        Schema schema = getParameterSchema(parameterClass);\n        if (schema == null) {\n          throw new RuntimeException(\"Could not determine a schema for type \" + parameterClass);\n        }\n        if (parameterRow != null && !parameterRow.getSchema().assignableTo(schema)) {\n          return false;\n        }\n      }","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java#L292-L328","documentation":"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.","triggerScenarios":"Array parameter of POJO/complex component type whose component class has no registered, non-empty schema in the SchemaRegistry at expansion time.","commonSituations":"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.","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."],"exampleFix":"// before\npublic MyTransform withItems(Item[] items) {...}  // Item has no schema\n// after\n@DefaultSchema(JavaFieldSchema.class)\nclass Item { public final String id; public Item(String id){this.id=id;} }","handlingStrategy":"validation","validationCode":"Class<?> comp = paramClass.getComponentType();\ntry {\n  Schema s = SchemaRegistry.getDefault().getSchema(comp);\n  if (s == null || s.getFieldCount() == 0) throw new IllegalStateException(\"Register a schema for array component \" + comp);\n} catch (NoSuchSchemaException e) { throw new IllegalStateException(\"No schema for \" + comp, e); }","typeGuard":null,"tryCatchPattern":"try {\n  return getTransform(payload);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Could not determine a schema for type\")) {\n    throw new InvalidExpansionRequest(\"Array component type lacks schema: \" + paramClass, e);\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["java","schema","array","beam-expansion-service"],"backgroundTag":"schema-validation-failed","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"}