{"record":{"id":"827a4ea9a7ef6100","repo":"apache/beam","slug":"could-not-determine-a-valid-schema-for-parameter-class","errorCode":null,"errorMessage":"Could not determine a valid schema for parameter class ","messagePattern":"Could not determine a valid schema for parameter class ","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":260,"sourceCode":"\n  private static boolean isPrimitiveOrWrapperOrString(java.lang.Class<?> type) {\n    return ClassUtils.isPrimitiveOrWrapper(type) || type == String.class;\n  }\n\n  private Schema getParameterSchema(Class<?> parameterClass) {\n    Schema parameterSchema;\n    try {\n      parameterSchema = SCHEMA_REGISTRY.getSchema(parameterClass);\n    } catch (NoSuchSchemaException e) {\n\n      SCHEMA_REGISTRY.registerSchemaProvider(parameterClass, new JavaFieldSchema());\n      try {\n        parameterSchema = SCHEMA_REGISTRY.getSchema(parameterClass);\n      } catch (NoSuchSchemaException e1) {\n        throw new RuntimeException(e1);\n      }\n      if (parameterSchema != null && parameterSchema.getFieldCount() == 0) {\n        throw new RuntimeException(\n            \"Could not determine a valid schema for parameter class \" + parameterClass);\n      }\n    }\n    return parameterSchema;\n  }\n\n  private boolean parametersCompatible(\n      java.lang.reflect.Parameter[] methodParameters, Row constructorRow) {\n    Schema constructorSchema = constructorRow.getSchema();\n    if (methodParameters.length != constructorSchema.getFieldCount()) {\n      return false;\n    }\n\n    for (int i = 0; i < methodParameters.length; i++) {\n      java.lang.reflect.Parameter parameterFromReflection = methodParameters[i];\n      Field parameterFromPayload = constructorSchema.getField(i);\n      String paramNameFromReflection = parameterFromReflection.getName();\n","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java#L242-L278","documentation":"The service asked the SchemaRegistry for a schema of a parameter class and either got a schema with zero fields (which cannot be mapped from the payload row) or had to wrap NoSuchSchemaException. A usable, non-empty schema is required to map payload rows onto the parameter type.","triggerScenarios":"Resolving a parameter type whose class has no registered schema, or whose schema registers zero fields (e.g. an empty @DefaultSchema class), during getParameterSchema used by arrayFieldSchema/schema paths.","commonSituations":"Parameter POJO missing @DefaultSchema annotation and schema provider; Java class compiled without schema field registration; using types like Object or maps not supported by the schema registry.","solutions":["Annotate the parameter class with @DefaultSchema(JavaFieldSchema.class) (or implement a SchemaProvider) and register it so SchemaRegistry can produce a non-empty schema.","Ensure the class has at least one schema-able field; empty classes cannot be mapped from payload rows.","Recompile so schema coders/field metadata are embedded, and redeploy the expansion service with the updated classes.","Use a supported parameter type (POJO, AVRO record, Row) instead of unstructured types."],"exampleFix":"// before\nclass Config { }\n// after\n@DefaultSchema(JavaFieldSchema.class)\nclass Config { public final String name; public Config(String name){this.name=name;} }","handlingStrategy":"validation","validationCode":"try {\n  Schema s = SchemaRegistry.getDefault().getSchema(Config.class);\n  if (s == null || s.getFieldCount() == 0) throw new IllegalStateException(\"Config has no usable schema; add @DefaultSchema and fields\");\n} catch (NoSuchSchemaException e) { throw new IllegalStateException(\"Register a schema for Config\", e); }","typeGuard":null,"tryCatchPattern":"try {\n  return getTransform(payload);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Could not determine a valid schema\")) {\n    throw new InvalidExpansionRequest(\"Parameter type lacks a registered non-empty schema\", e);\n  }\n  throw e;\n}","preventionTips":["Annotate every parameter POJO with @DefaultSchema(JavaFieldSchema.class) or an AVRO/POJO provider.","Never use field-less classes as builder parameters for expansion.","Register custom SchemaProviders before serving expansion requests.","Verify schema resolution in unit tests via SchemaRegistry.getSchema()."],"tags":["java","schema","beam","schema-registry"],"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"}