apache/pulsar · error · AvroRuntimeException
Schema typed [<schema.getClass().getName()>], simple-type:[<
Error message
Schema typed [<schema.getClass().getName()>], simple-type:[<schema.getType()>] is not supported. schema-content: <schema>
What it means
GenericSchemaImpl's constructor extracts field names/positions from the underlying Avro schema via schema.getFields(). If the schema object does not support Avro field access, Avro throws AvroRuntimeException, which is rethrown with a rewritten message naming the schema class, simple type, and content. It means the supplied schema cannot be used as an Avro generic record schema.
Source
Thrown at pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericSchemaImpl.java:51
* we suggest migrate GenericSchemaImpl.of() to <GenericSchema Implementor>.of() method
* (e.g. GenericJsonSchema 、GenericAvroSchema )
*/
public abstract class GenericSchemaImpl extends AvroBaseStructSchema<GenericRecord>
implements GenericSchema<GenericRecord> {
protected final List<Field> fields;
protected GenericSchemaImpl(SchemaInfo schemaInfo) {
super(schemaInfo);
try {
this.fields = schema.getFields()
.stream()
.map(f -> new Field(f.name(), f.pos()))
.collect(Collectors.toList());
} catch (AvroRuntimeException avroRuntimeException) {
// Rewrite error log.
throw new AvroRuntimeException("Schema typed [" + schema.getClass().getName() + "], simple-type:["
+ schema.getType() + "] is not supported. schema-content: " + schema);
}
}
@Override
public List<Field> getFields() {
return fields;
}
/**
* Create a generic schema out of a <tt>SchemaInfo</tt>.
* warning : we suggest migrate GenericSchemaImpl.of() to <GenericSchema Implementor>.of() method
* (e.g. GenericJsonSchema 、GenericAvroSchema )
* @param schemaInfo schema info
* @return a generic schema instance
*/
public static GenericSchemaImpl of(SchemaInfo schemaInfo) {
return of(schemaInfo, true);View on GitHub (pinned to 820761864e)
Solutions
- Verify the schema is an Avro RECORD type before wrapping it in GenericSchemaImpl
- Check the schema content printed in the message for malformed JSON/Avro syntax
- Use SchemaInfo with a valid record-type Avro definition
- Catch AvroRuntimeException at construction and surface a clear validation error to the caller
Example fix
// before
GenericSchemaImpl.of(badSchemaInfo); // AvroRuntimeException
// after
if (SchemaType.AVRO.equals(badSchemaInfo.getType()) && isValidAvroRecordSchema(badSchemaInfo.getSchema())) {
GenericSchemaImpl.of(badSchemaInfo);
} else {
throw new IllegalArgumentException("SchemaInfo must contain a valid Avro RECORD schema");
} Defensive patterns
Strategy: validation
Validate before calling
Schema avroSchema = new Schema.Parser().setValidate(true).parse(new String(schemaInfo.getSchema(), StandardCharsets.UTF_8));
if (avroSchema.getType() != Schema.Type.RECORD) {
throw new IllegalArgumentException("GenericSchemaImpl requires an Avro RECORD schema, got: " + avroSchema.getType());
} Type guard
boolean isAvroRecordSchema(SchemaInfo info) {
try {
return new Schema.Parser().parse(new String(info.getSchema(), StandardCharsets.UTF_8)).getType() == Schema.Type.RECORD;
} catch (RuntimeException e) {
return false;
}
} Try / catch
try {
GenericSchemaImpl.of(schemaInfo);
} catch (AvroRuntimeException e) {
log.error("Schema not usable as Avro generic record schema: {}", e.getMessage());
throw new IllegalArgumentException("Provide a valid Avro RECORD schema", e);
} Prevention
- Validate Avro schema JSON with Schema.Parser before constructing generic schemas
- Only pass RECORD-type Avro schemas to generic record schema APIs
- Never hand-edit SchemaInfo schema bytes without validating them
- Log schema content on failure — the message already includes it
When it happens
Trigger: Constructing GenericSchemaImpl (directly or via a subclass) with a Schema object whose getFields() raises AvroRuntimeException — e.g. a primitive-typed schema, malformed Avro schema, or a non-record schema passed where a record schema is required.
Common situations: Passing a primitive schema (STRING/INT) instead of a record schema; corrupt or hand-written SchemaInfo JSON that Avro cannot parse; programmatically constructed Avro schemas of unexpected type (ARRAY, MAP) fed to the generic record schema.
Related errors
- Avro Record Builder doesn't support non-avro record as a fie
- Generic schema is not supported on schema type <schemaInfo.g
- Can't get generic schema for topic <schemaInfoProvider.getTo
- Can not enable for all producers but denies for replicators,
- Failed to add schema to an active topic with empty(BYTES) sc
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/43ed75db8fb2876f.
Report an issue: GitHub.