confluentinc / confluentinc/confluent-kafka-javascript

Unable To Register Schema With References

Open
#265 0 comments 0 reactions 0 assignees View on GitHub
component:schema-registry
Dominant language
TypeScript
Stars
304
Forks
45
Avg merge
11h 47m
Merged PRs (30d)
5

Description

**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**
1) Create avsc files where file one references another file
2) Use schema registry client to try to register schemas

**Additional context**
```shell
Error: Failed to update schema registry: Error registering subject 'schema-with-reference-value':
details: Undefined name: "namespaced.SchemaObject"; Error code: 42201
```

schemaWithReference.avsc
```json
{
"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
```json
{
"name": "SchemaObject",
"type": "record",
"namespace": "namespaced",
"fields": [
{
"name": "textField",
"type": "string"
}
]
}
```

index.js
```javascript
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,
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.