Skip to content

ProtobufSerializer Error: message type name is empty #217

Open
@baumac

Description

@baumac

Description

When attempting to serialize messages using the ProtobufSerializer an error is always thrown.

Environment Information

  • OS Mac M1 Sonoma 14.6.1
  • Node Version 20.18.1
  • NPM Version 10.8.2:
  • confluent-kafka-javascript version 1.0.0:

Steps to Reproduce
Execute the below code and it will throw the following error:

Error: message type name is empty
    at ProtobufSerializer.serialize (/Users/christopher.baumann@konghq.com/Develop/other/confluent-kafka-javascript/schemaregistry/serde/protobuf.ts:146:13)
    at Object.<anonymous> (/Users/christopher.baumann@konghq.com/Develop/other/confluent-kafka-javascript/schemaregistry/e2e/schemaregistry-proto.spec.ts:84:31)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Code to reproduce: a test example has been created in #218 (comment)

   const schemaString: string = "\n" +
     "syntax = \"proto3\";\n" +
     "message TestMessageValue {\n" +
     "  string name = 1;\n" +
     "  int32 age = 2;\n" +
     "\n" +
    "}\n";
    
   const messageValue = {
     "name": "Bob Jones",
     "age": 25
    };
    
   const schemaInfo: SchemaInfo = {
     schema: schemaString,
     schemaType: 'PROTOBUF'
    };

   const testTopic = "test";

   const schemaRegistryClient = new SchemaRegistryClient(clientConfig);
   await schemaRegistryClient.register(testTopic + "-value", schemaInfo);

   serializerConfig = { useLatestVersion: true };
   serializer = new ProtobufSerializer(schemaRegistryClient, SerdeType.VALUE, serializerConfig);
   deserializer = new ProtobufDeserializer(schemaRegistryClient, SerdeType.VALUE, {});
  
   const outgoingMessage = {
      key: 'key',
      value: await serializer.serialize(testTopic, messageValue)
    };

Additional context
When trying to serialize a message using the ProtoSerializer an error is thrown. The expected behavior is that the serialize should be able to successfully serialize messages.

Note: If the above code is changed to include the $typeName then the error changes to the following:

Error: message descriptor not in registry

    at ProtobufSerializer.serialize (/Users/christopher.baumann@konghq.com/Develop/other/confluent-kafka-javascript/schemaregistry/serde/protobuf.ts:150:13)
    at Object.<anonymous> (/Users/christopher.baumann@konghq.com/Develop/other/confluent-kafka-javascript/schemaregistry/e2e/schemaregistry-proto.spec.ts:84:31)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Code to reproduce:

   const outgoingMessage = {
      key: 'key',
      value: await serializer.serialize(testTopic, { ...messageValue, $typeName: "TestMessageValue"})
    };

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions