apache/pulsar · error · IllegalArgumentException

Retrieve schema instance from schema info for type '${schema

Error message

Retrieve schema instance from schema info for type '${schemaInfo.getType}' is not supported yet

What it means

AutoConsumeSchema.generateSchema/getSchema converts a broker-provided SchemaInfo back into a Schema instance. When the SchemaInfo's type has no implemented reverse mapping (any type outside the supported NATIVE_AVRO/PROTOS/JSON/KEY_VALUE etc. cases), it throws IllegalArgumentException stating the type is not supported yet.

Source

Thrown at pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AutoConsumeSchema.java:273

                return LocalDateSchema.of();
            case LOCAL_TIME:
                return LocalTimeSchema.of();
            case LOCAL_DATE_TIME:
                return LocalDateTimeSchema.of();
            case JSON:
            case AVRO:
                return GenericSchemaImpl.of(schemaInfo, false);
            case PROTOBUF_NATIVE:
                return GenericProtobufNativeSchema.of(schemaInfo);
            case KEY_VALUE:
                KeyValue<SchemaInfo, SchemaInfo> kvSchemaInfo =
                        KeyValueSchemaInfo.decodeKeyValueSchemaInfo(schemaInfo);
                Schema<?> keySchema = getSchema(kvSchemaInfo.getKey());
                Schema<?> valueSchema = getSchema(kvSchemaInfo.getValue());
                return KeyValueSchemaImpl.of(keySchema, valueSchema,
                        KeyValueSchemaInfo.decodeKeyValueEncodingType(schemaInfo));
            default:
                throw new IllegalArgumentException("Retrieve schema instance from schema info for type '"
                        + schemaInfo.getType() + "' is not supported yet");
        }
    }

    public Schema<GenericRecord> clone() {
        AutoConsumeSchema schema = new AutoConsumeSchema();
        schema.configureSchemaInfo(topicName, componentName, null);
        if (schemaInfoProvider != null) {
            schema.setSchemaInfoProvider(schemaInfoProvider);
        }
        for (Map.Entry<SchemaVersion, Schema<?>> entry : schemaMap.entrySet()) {
            schema.setSchema(entry.getKey(), entry.getValue());
        }
        return schema;
    }

    @Override
    public boolean requireFetchingSchemaInfo() {

View on GitHub (pinned to 820761864e)

Solutions

  1. Upgrade the Pulsar client to a version that supports the schema type in AutoConsumeSchema.getSchema
  2. Re-register the topic schema with a supported type (AVRO/JSON/Protobuf/KeyValue)
  3. Consume with a plain byte schema (Schema.BYTES) and deserialize manually if the type cannot be supported

Example fix

// before
Consumer<GenericRecord> c = client.newConsumer().schema(Schema.AUTO_CONSUME())... // topic type unsupported
// after
Consumer<byte[]> c = client.newConsumer().schema(Schema.BYTES)...;
// deserialize manually, or upgrade client
Defensive patterns

Strategy: try-catch

Validate before calling

SchemaType type = schemaInfo.getType();
Set<SchemaType> supported = Set.of(SchemaType.AVRO, SchemaType.JSON, SchemaType.PROTOBUF,
    SchemaType.PROTOBUF_NATIVE, SchemaType.KEY_VALUE);
if (!supported.contains(type)) {
    // do not attempt AUTO_CONSUME for this topic
}

Type guard

boolean isAutoConsumeSupportedType(SchemaInfo info) {
    return info != null && EnumSet.of(SchemaType.AVRO, SchemaType.JSON,
        SchemaType.PROTOBUF_NATIVE, SchemaType.KEY_VALUE).contains(info.getType());
}

Try / catch

try {
    Schema<GenericRecord> s = Schema.AUTO_CONSUME();
} catch (IllegalArgumentException e) {
    // fall back to Schema.BYTES and manual decoding
}

Prevention

When it happens

Trigger: A topic's schema is registered with a SchemaType that AutoConsumeSchema cannot instantiate (e.g. primitive types not covered by the switch, or exotic/custom types), and a consumer with Schema.AUTO_CONSUME() fetches that schema info.

Common situations: Topics whose schema was registered with unusual or legacy SchemaTypes; brokers upgraded with newer schema types while the client library is older and lacks the mapping; KeyValue schemas with unsupported inner types.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/cd84e7b0b37499bd. Report an issue: GitHub.