confluent-kafka-javascript
confluent-kafka-javascript copied to clipboard
Unable To Register Schema With References
Environment Information
- OS [e.g. Mac, Arch, Windows 10]: MacOS 15.3.1
- Node Version [e.g. 8.2.1]: v22.14.0
- NPM Version [e.g. 5.4.2]: 10.9.2
- C++ Toolchain [e.g. Visual Studio, llvm, g++]: llvm
- @confluentinc/kafka-javascript version [e.g. 2.3.3]: 1.2.0
- @confluentinc/schemaregistry version [e.g. 2.3.3]: 1.1.0
Steps to Reproduce
- Create avsc files where file one references another file
- Use schema registry client to try to register schemas
Additional context
Error: Failed to update schema registry: Error registering subject 'schema-with-reference-value': <schema>
details: Undefined name: "namespaced.SchemaObject"; Error code: 42201
schemaWithReference.avsc
{
"name": "schemaWithReference",
"namespace": "namespaced",
"type": "record",
"fields": [
{
"name": "textField",
"type": {
"type": "string",
"avro.java.string": "String"
}
},
{
"name": "arrayOfObjects",
"type": {
"type": "array",
"items": "namespaced.SchemaObject",
"default": []
}
}
]
}
schemaObject.avsc
{
"name": "SchemaObject",
"type": "record",
"namespace": "namespaced",
"fields": [
{
"name": "textField",
"type": "string"
}
]
}
index.js
import { readFile } from "fs/promises";
import { SchemaRegistryClient } from "@confluentinc/schemaregistry";
const registry = new SchemaRegistryClient({
baseURLs: ["http://localhost:8081"],
});
const file1 = await readFile("./schemaObject.avsc", "utf8");
await registry.registerFullResponse("schema-object-value", {
schemaType: "AVRO",
schema: file1,
});
const file2 = await readFile("./schemaWithReference.avsc", "utf8");
await registry.registerFullResponse("schema-with-reference-value", {
schemaType: "AVRO",
schema: file2,
});