confluent-kafka-javascript icon indicating copy to clipboard operation
confluent-kafka-javascript copied to clipboard

fetchTopicMetadata types incorrect

Open MMM-J opened this issue 3 months ago • 3 comments

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.

MMM-J avatar Sep 17 '25 14:09 MMM-J

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
  },
  ...

mbazalik avatar Sep 22 '25 19:09 mbazalik

Thanks for filing this. We'll have to change the types and add a notice to the migration guide.

milindl avatar Sep 29 '25 05:09 milindl

thanks @milindl any updates on this bug?

nash-trac avatar Nov 06 '25 18:11 nash-trac