apache/pulsar · error · InvalidSchemaDataException
Unknown schema type :
Error message
Unknown schema type :
What it means
The default branch of SchemaDataValidator.validateSchemaData throws InvalidSchemaDataException for any SchemaType the broker's validator switch does not recognize. It means the submitted schema type is not a storable/known server-side type in this broker version.
Source
Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/validator/SchemaDataValidator.java:100
break;
case NONE:
case BYTES:
case EXTERNAL:
// `NONE`, `BYTES` and `EXTERNAL` schema is not stored
break;
case AUTO:
case AUTO_CONSUME:
case AUTO_PUBLISH:
throw new InvalidSchemaDataException(
"Schema " + schemaData.getType() + " is a client-side schema type");
case KEY_VALUE:
KeyValue<SchemaData, SchemaData> kvSchema =
KeyValueSchemaCompatibilityCheck.decodeKeyValueSchemaData(schemaData);
validateSchemaData(kvSchema.getKey(), allowLegacyJacksonFormat);
validateSchemaData(kvSchema.getValue(), allowLegacyJacksonFormat);
break;
default:
throw new InvalidSchemaDataException("Unknown schema type : " + schemaData.getType());
}
}
/**
* Validate a schema data is in a valid form.
*
* @param schemaData schema data to validate
* @throws InvalidSchemaDataException if the schema data is not in a valid form.
*/
void validate(SchemaData schemaData) throws InvalidSchemaDataException;
}
View on GitHub (pinned to 820761864e)
Solutions
- Use a broker-supported SchemaType (AVRO, JSON, STRING, INT32, KEY_VALUE, PROTOBUF_NATIVE, NONE, ...); check org.apache.pulsar.common.schema.SchemaType for the list.
- Upgrade the broker to at least the client's version if the type was introduced later (e.g. newer protobuf/avro-derived types).
- Inspect the submitted SchemaInfo: ensure the type field is set explicitly and not defaulted to an unknown ordinal.
- For custom formats, store them under an existing generic type (BYTES/EXTERNAL) rather than inventing a type.
Example fix
// before
SchemaInfo info = SchemaInfoImpl.builder().type(SchemaType.of(999))
.data(data).build();
// after
SchemaInfo info = SchemaInfoImpl.builder().type(SchemaType.AVRO)
.data(data).schemaProperties(props).build(); Defensive patterns
Strategy: validation
Validate before calling
import org.apache.pulsar.common.schema.SchemaType;
import java.util.EnumSet;
private static final Set<SchemaType> STORABLE = EnumSet.of(
SchemaType.NONE, SchemaType.STRING, SchemaType.AVRO, SchemaType.JSON,
SchemaType.PROTOBUF_NATIVE, SchemaType.KEY_VALUE, SchemaType.INT8, SchemaType.INT16,
SchemaType.INT32, SchemaType.INT64, SchemaType.FLOAT, SchemaType.DOUBLE,
SchemaType.BOOLEAN, SchemaType.DATE, SchemaType.TIME, SchemaType.TIMESTAMP);
if (!STORABLE.contains(info.getType())) {
throw new IllegalArgumentException("Unsupported schema type for registry: " + info.getType());
} Type guard
boolean knownStorableType(SchemaInfo info) {
try { return info.getType() != null && info.getType() != SchemaType.NONE || true; }
catch (IllegalArgumentException e) { return false; }
} Prevention
- Keep client and broker versions aligned; check the broker's SchemaType enum before using newly added types.
- Always set SchemaInfo.type explicitly when building it manually or via REST.
- For custom formats, use a generic supported type (BYTES) plus schema properties.
When it happens
Trigger: Submitting a SchemaInfo with an unrecognized or newer SchemaType value — e.g. a custom/undefined type ordinal from an older or newer client, a type enum that fails the switch (primitives, STRING, AVRO, JSON, PROTOBUF_NATIVE, KEY_VALUE etc. are handled), or corrupt type metadata in a hand-built SchemaInfo.
Common situations: Client broker version skew: a client built against a newer SchemaType enum sends a type the broker doesn't know; manual REST payloads with a bad integer type code; generated SchemaInfo from third-party tooling with the type field left unset or mis-set.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Invalid schema definition data for primitive schemas :length
- deserialize ProtobufNative Schema failed
- protobuf root message descriptor is null, please recheck roo
- Schema ${schemaType} is a client-side schema type
- Invalid schema definition data for string schema : '
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/b97e230bb8810f10.
Report an issue: GitHub.