Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProtobufSerializer Error: message type name is empty #217

Open
baumac opened this issue Dec 17, 2024 · 4 comments
Open

ProtobufSerializer Error: message type name is empty #217

baumac opened this issue Dec 17, 2024 · 4 comments

Comments

@baumac
Copy link

baumac commented Dec 17, 2024

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/[email protected]/Develop/other/confluent-kafka-javascript/schemaregistry/serde/protobuf.ts:146:13)
    at Object.<anonymous> (/Users/[email protected]/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/[email protected]/Develop/other/confluent-kafka-javascript/schemaregistry/serde/protobuf.ts:150:13)
    at Object.<anonymous> (/Users/[email protected]/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"})
    };
@baumac baumac changed the title Protobuf Serializer Error: message type name is empty ProtobufSerializer Error: message type name is empty Dec 17, 2024
@rayokota
Copy link
Member

@baumac , are you using Schema Registry from CP? If so, which version?

@baumac
Copy link
Author

baumac commented Dec 19, 2024

@rayokota yup was using the confluentinc/cp-schema-registry:7.7.1 docker image.

I also opened up a PR here that contains a test case that replicates the error #218

@rayokota
Copy link
Member

@baumac, for Protobuf, this library needs changes from confluentinc/schema-registry#3276, which will be in the next CP patch releases.

@baumac
Copy link
Author

baumac commented Dec 20, 2024

@rayokota that's great news, is there a ticket or GH issue we can be tracking to know when the Protobuf Serde tooling will be working in the @confluentinc/schemaregistry package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants