Description
ProtobufDeserializer fails to parse protobuf schemas that contain enums defined at the file/package level (outside of any message). The error is:
invalid FieldDescriptorProto: type_name MyEnum not found
Schemas with the same enum nested inside a message deserialize correctly.
Environment
@confluentinc/schemaregistry: 1.8.0
- Node: 22.15.0
- OS: macOS (darwin arm64)
Minimal reproduction
Works — enum nested inside a message:
syntax = "proto3";
package test;
message MyMessage {
enum MyEnum {
MY_ENUM_UNSPECIFIED = 0;
MY_ENUM_FOO = 1;
}
optional MyEnum my_field = 1;
}
Fails — enum at file level (valid proto3):
syntax = "proto3";
package test;
message MyMessage {
optional MyEnum my_field = 1;
}
enum MyEnum {
MY_ENUM_UNSPECIFIED = 0;
MY_ENUM_FOO = 1;
}
import { SchemaRegistryClient } from '@confluentinc/schemaregistry';
import { ProtobufDeserializer } from '@confluentinc/schemaregistry/serde/protobuf';
const client = new SchemaRegistryClient({
baseURLs: ['http://localhost:8081'],
basicAuthCredentials: { credentialsSource: 'USER_INFO', userInfo: 'user:pass' },
});
const deserializer = new ProtobufDeserializer(client, 1 /* VALUE */, {});
// Register the "fails" schema above, obtain its schema ID, then:
const buf = Buffer.alloc(6);
buf[0] = 0x00; // magic byte
buf.writeInt32BE(schemaId, 1); // schema ID
buf[5] = 0x00; // message index (first type)
await deserializer.deserialize('my-topic', buf);
// => throws: invalid FieldDescriptorProto: type_name MyEnum not found
Expected behavior
File-level enums are valid proto3 and commonly used when an enum is shared across multiple messages in the same file. The deserializer should resolve the type reference correctly regardless of whether the enum is defined inside or outside a message.
Impact
This blocks deserialization of any protobuf topic whose registered schema defines enums at the file level. This is a common pattern in production proto files — particularly in multi-message schemas where enums are shared across message types.
Description
ProtobufDeserializerfails to parse protobuf schemas that contain enums defined at the file/package level (outside of any message). The error is:Schemas with the same enum nested inside a message deserialize correctly.
Environment
@confluentinc/schemaregistry: 1.8.0Minimal reproduction
Works — enum nested inside a message:
Fails — enum at file level (valid proto3):
Expected behavior
File-level enums are valid proto3 and commonly used when an enum is shared across multiple messages in the same file. The deserializer should resolve the type reference correctly regardless of whether the enum is defined inside or outside a message.
Impact
This blocks deserialization of any protobuf topic whose registered schema defines enums at the file level. This is a common pattern in production proto files — particularly in multi-message schemas where enums are shared across message types.