I'm using kafkajs
and @kafkajs/confluent-schema-registry
in Typescript in order to encode a message payload using proto and send it to Kafka. When I try to encode the message, it fails with the following error:
/Users/test-user/Documents/Workspace/typescript-producer/node_modules/@kafkajs/confluent-schema-registry/node_modules/protobufjs/src/namespace.js:411
throw Error("no such Type or Enum '" + path + "' in " + this);
^
Error: no such Type or Enum 'google.protobuf.Timestamp' in Type .kafka.data_tests.v0.User
at Type.lookupTypeOrEnum (/Users/test-user/Documents/Workspace/typescript-producer/node_modules/@kafkajs/confluent-schema-registry/node_modules/protobufjs/src/namespace.js:411:15)
at Field.resolve (/Users/test-user/Documents/Workspace/typescript-producer/node_modules/@kafkajs/confluent-schema-registry/node_modules/protobufjs/src/field.js:268:94)
at Type.setup (/Users/test-user/Documents/Workspace/typescript-producer/node_modules/@kafkajs/confluent-schema-registry/node_modules/protobufjs/src/type.js:435:41)
at Type.verify_setup [as verify] (/Users/test-user/Documents/Workspace/typescript-producer/node_modules/@kafkajs/confluent-schema-registry/node_modules/protobufjs/src/type.js:529:17)
at ProtoSchema.isValid (/Users/test-user/Documents/Workspace/typescript-producer/node_modules/@kafkajs/confluent-schema-registry/src/ProtoSchema.ts:64:48)
at SchemaRegistry.collectInvalidPaths (/Users/test-user/Documents/Workspace/typescript-producer/node_modules/@kafkajs/confluent-schema-registry/src/SchemaRegistry.ts:210:12)
at SchemaRegistry.encode (/Users/test-user/Documents/Workspace/typescript-producer/node_modules/@kafkajs/confluent-schema-registry/src/SchemaRegistry.ts:203:26)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async main (/Users/test-user/Documents/Workspace/typescript-producer/producer-with-schema-code.ts:67:28)
This is the proto schema:
syntax = "proto3";
package kafka.data_tests.v0;
import "google/protobuf/timestamp.proto";
message User {
string name = 1;
string surname = 2;
bool employee = 3;
google.protobuf.Timestamp created_at = 4;
}
I have the following dependencies installed:
"devDependencies": {
"@kafkajs/confluent-schema-registry": "^3.2.1",
"@types/google-protobuf": "^3.15.6",
"@types/node": "^14.11.2",
"@types/uuid": "^8.3.4",
"google-protobuf": "^3.20.1",
"gts": "^3.1.0",
"kafkajs": "^2.1.0",
"protobufjs": "^7.0.0",
"ts-protoc-gen": "^0.15.0",
"typescript": "^4.7.4",
"uuid": "^8.3.2"
}
Any ideas on how to solve this issue?