apache/pulsar · error · RuntimeException
Unsupported schema type${type}
Error message
Unsupported schema type${type} What it means
TopicSchema.newSchemaInstance maps a SchemaType to a concrete Schema implementation for function input/output topics. Thrown when the configured schema type has no supported instantiation path in this switch (default branch), typically a schema type the function runtime doesn't know how to build.
Source
Thrown at pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/source/TopicSchema.java:190
.withPojo(clazz).build());
case JSON:
return JSONSchema.of(SchemaDefinition.<T>builder().withPojo(clazz).build());
case KEY_VALUE:
return (Schema<T>) Schema.KV_BYTES();
case PROTOBUF:
return ProtobufSchema.ofGenericClass(clazz, new HashMap<>());
case PROTOBUF_NATIVE:
return ProtobufNativeSchema.ofGenericClass(clazz, new HashMap<>());
case AUTO_PUBLISH:
return (Schema<T>) Schema.AUTO_PRODUCE_BYTES();
default:
throw new RuntimeException("Unsupported schema type" + type);
}
}
private static boolean isProtobufClass(Class<?> pojoClazz) {
try {
Class<?> protobufBaseClass = Class.forName("com.google.protobuf.Message");
return protobufBaseClass.isAssignableFrom(pojoClazz);
} catch (ClassNotFoundException | NoClassDefFoundError e) {
// If function does not have protobuf in classpath then it cannot be protobuf
return false;
}
}
@SuppressWarnings("unchecked")
private <T> Schema<T> newSchemaInstance(String topic, Class<T> clazz, String schemaTypeOrClassName, boolean input,
ClassLoader classLoader) {
return newSchemaInstance(topic, clazz, new ConsumerConfig(schemaTypeOrClassName), input, classLoader);
}View on GitHub (pinned to 820761864e)
Solutions
- Set an explicitly supported schemaType in the function config (STRING, JSON, AVRO, PROTOBUF, AUTO_CONSUME/AUTO_PUBLISH as supported by your version).
- Use the Java class name (serdeClassname) with a built-in type instead of an exotic schema type.
- Upgrade the function instance runtime if the schema type is from a newer Pulsar release.
Example fix
// before (functions.yml) schemaType: KEY_VALUE // after schemaType: JSON // or use class-based config className: com.google.protobuf.Message
Defensive patterns
Strategy: validation
Validate before calling
Set<String> supported = Set.of("STRING","JSON","AVRO","PROTOBUF","PROTOBUF_NATIVE","AUTO_CONSUME","AUTO_PUBLISH");
String t = fnConfig.getOutputSchemaType();
if (!supported.contains(t)) {
throw new IllegalArgumentException("schemaType " + t + " not supported by this runtime");
} Try / catch
try {
Schema<T> s = topicSchema.getSchema(topic, clazz, conf, type, ...);
} catch (RuntimeException e) {
if (e.getMessage().startsWith("Unsupported schema type")) {
// fall back to a supported type or upgrade the runtime
}
} Prevention
- Pin schemaType to values supported by the deployed Pulsar version
- Prefer explicit serde class names over inferred schema types
- Test function configs against the target runtime version before release
When it happens
Trigger: Function config declares a schema type (schemaType / serialization class resolution) that reaches the default case, e.g. KEY_VALUE, AVRO variants, or AUTO_CONSUME used where unsupported, instead of the handled types (STRING, JSON, AVRO, PROTOBUF, PROTOBUF_NATIVE, AUTO_PUBLISH, etc.).
Common situations: Misconfigured function YAML (wrong schemaType string); using a newer schema type with an older function instance; letting the runtime infer a type that maps to an unhandled enum constant.
Related errors
- Schema should not be null.
- Config class not found: %s
- Unsupported schema type%s
- Unknown component type: ${componentType}
- Batch Configs cannot be found
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/a094f130efa59051.
Report an issue: GitHub.