confluent-kafka-javascript
confluent-kafka-javascript copied to clipboard
fetchTopicMetadata types incorrect
Environment Information
- OS: Debian
- Node Version: v22.16.0
- confluent-kafka-javascript version: 1.4.1
Steps to Reproduce Topic metadata is not wrapped in an outer holder-object, but the typescript types say they are.
Using the promisified api:
import { KafkaJS } from '@confluentinc/kafka-javascript';
const { Kafka, ErrorCodes, CompressionTypes } = KafkaJS;
const admin = new Kafka().admin({
'bootstrap.servers': `localhost:9092`
});
await admin.connect();
const topicsMetadata = await admin.fetchTopicMetadata({
topics: ['test-topic']
});
console.dir(topicsMetadata, { depth: null });
The output is:
[
{
name: 'test-topic',
...
}
]
But the typescript signature is:
fetchTopicMetadata(options?: {
topics?: string[],
includeAuthorizedOperations?: boolean,
timeout?: number
}): Promise<{ topics: Array<ITopicMetadata> }>
That outer { topics: ... } is incorrect.
having same issue, the actual response looks like
[
{
name: 'kafka_client-dlq',
topicId: {
mostSignificantBits: 7288185016215552264n,
leastSignificantBits: -7969400969335078165n,
base64: 'ZSTVqGTaQQiRZwAKxiEC6w'
},
isInternal: false,
partitions: [ [Object] ],
authorizedOperations: undefined
},
{
name: 'kafka_client',
topicId: {
mostSignificantBits: 7613720909136676950n,
leastSignificantBits: -6014673702620945490n,
base64: 'aale0+AOSFash5Yic2Ujrg'
},
isInternal: false,
partitions: [
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object],
[Object], [Object]
],
authorizedOperations: undefined
},
...
Thanks for filing this. We'll have to change the types and add a notice to the migration guide.
thanks @milindl any updates on this bug?