apache/druid · error · ParseException
Fail to get protobuf schema because of invalid schema!
Error message
Fail to get protobuf schema because of invalid schema!
What it means
After fetching the schema by id, the decoder converts it to a protobuf Descriptor via schema.toDescriptor(). If that fails with an IOException, the stored schema is not a usable/valid protobuf schema, and Druid throws a ParseException with this message.
Solutions
- Confirm the subject/schema for the consumed ids was registered with the PROTOBUF format, not Avro/JSON
- Re-register the correct .proto schema under the subject and republish or use the correct schema id
- Check that ProtobufSchemaProvider is configured in the decoder and registry compatibility settings allow the protobuf type
Example fix
// before: subject registered as AVRO
$ kafka-avro-console-producer --property schema.registry.url=...
// after: register protobuf schema
curl -X POST http://registry:8081/subjects/mytopic-value/versions -H 'Content-Type: application/vnd.schemaregistry.v1+json' -d '{"schemaType":"PROTOBUF","schema":"syntax=\"proto3\"; message Msg { ... }"}' Defensive patterns
Strategy: validation
Validate before calling
Schema schema = registry.getSchemaById(id);
if (!(schema instanceof ProtobufSchema)) {
throw new IllegalStateException("Schema id " + id + " is not PROTOBUF type: " + schema.schemaType());
} Try / catch
try {
byte[] parsed = decoder.parse(bytes);
} catch (ParseException e) {
if (e.getMessage().contains("invalid schema")) {
log.error("Registered schema for id is not a valid protobuf schema; re-register with schemaType=PROTOBUF", e.getCause());
}
} Prevention
- Register subjects explicitly with schemaType=PROTOBUF
- Reject Avro/JSON-schema producers writing to topics consumed by this decoder
- Validate registry contents with a script that decodes each schema id as ProtobufSchema
When it happens
Trigger: registry.getSchemaById succeeds but ProtobufSchema.toDescriptor() throws IOException — the schema stored under the id is not a valid protobuf schema (e.g. registered as Avro/JSON in the same registry, or corrupt schema text).
Common situations: Using this decoder against a registry where subjects were registered with the wrong serialization format; manually edited or corrupted schema entries; protobufSchemaProvider misconfiguration.
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
- Duplicate spatial dimension names found! Check your schema…
- Fail to decode protobuf message!
- Fail to get protobuf schema because of can not connect to…
- Failed to authenticate to schema registry for Avro schema id
- Failed to decode Avro message for schema id
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/9e9b96b31b6d0386.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-core/protobuf-extensions/src/main/java/org/apache/druid/data/input/protobuf/SchemaRegistryBasedProtobufBytesDecoder.java:195
int id = bytes.getInt(); // extract schema registry id
bytes.get(); // ignore \0 byte before PB message
int length = bytes.limit() - 2 - 4;
Descriptors.Descriptor descriptor;
try {
ProtobufSchema schema = (ProtobufSchema) registry.getSchemaById(id);
descriptor = schema.toDescriptor();
}
catch (RestClientException e) {
LOGGER.error(e.getMessage());
throw new ParseException(
null,
e,
"Fail to get protobuf schema because of can not connect to registry or failed http request!"
);
}
catch (IOException e) {
LOGGER.error(e.getMessage());
throw new ParseException(null, e, "Fail to get protobuf schema because of invalid schema!");
}
try {
byte[] rawMessage = new byte[length];
bytes.get(rawMessage, 0, length);
return DynamicMessage.parseFrom(descriptor, rawMessage);
}
catch (Exception e) {
LOGGER.error(e.getMessage());
throw new ParseException(null, e, "Fail to decode protobuf message!");
}
}
@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}View on GitHub (pinned to 9b90983fd2)