Skip to content

Upgrade kafka-javascript; remove wrong typing workarounds#682

Open
James Robinson (jlrobins) wants to merge 1 commit into
mainfrom
maint/upgrade-and-remove-kafkajs-typing-workarounds
Open

Upgrade kafka-javascript; remove wrong typing workarounds#682
James Robinson (jlrobins) wants to merge 1 commit into
mainfrom
maint/upgrade-and-remove-kafkajs-typing-workarounds

Conversation

@jlrobins

@jlrobins James Robinson (jlrobins) commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Upgrade @confluentinc/kafka-javascript, drop typing issues workarounds

  • Bumped @confluentinc/kafka-javascript specification from 1.3.2 to 1.10.0 (in reality, going from 1.9.0 to 1.10.0). The three upstream type/runtime mismatches we'd worked around (fetchTopicMetadata types incorrect confluent-kafka-javascript#367, Document optional Armorer Guard MCP proxy #487, list-consumer-groups tool #489) were all fixed in 1.9.1; 1.10.0 is the current latest and carries no breaking changes over 1.3.2 per the library's changelog.
  • Deleted topic-metadata.ts's normalizeFetchTopicMetadataResponse() (and its test file) now that admin.fetchTopicMetadata() is correctly typed as Promise<Array<ITopicMetadata>> (Thread connectionId through tool handlers that depend on connection-specific config #367 fix) — call sites in get-consumer-group-lag-handler.ts and consume-kafka-messages-handler.ts consume the array directly.
  • Simplified describe-consumer-group-handler.ts's buildAssignment() to a single member.assignment.topicPartitions.map(...) — the dual-shape defensive branch (flat array vs. {topicPartitions} wrapper) and its "Wacky" fallback log are gone now that the upstream MemberDescription.assignment type honestly declares the wrapper (Document optional Armorer Guard MCP proxy #487 fix; upstream even adopted the MemberAssignment named type and Buffer | null suggestion from our issue write-up verbatim).
  • Dropped the loose-equality (!= null) workaround for FetchOffsetsPartition.error in get-consumer-group-lag-handler.ts in favor of a strict !== null check — the type is now honestly LibrdKafkaError | null (list-consumer-groups tool #489 fix), so undefined is no longer part of its domain.
  • Left consumer-group-helpers.ts's GroupDescription.error != null loose-equality check untouched: that field is still typed LibrdKafkaError | undefined upstream while runtime populates null, a distinct, still-open mismatch not covered by Remove workarounds and tests over workarounds when the next confluent-kafka-javascript release happens #514's tracked issues (367/487/489).
  • Verified via tsc --noEmit, pnpm run lint, and pnpm run test:unit (128 files / 2408 tests, all green) plus a diff-line coverage check — every changed line in the four touched handler/helper files is covered.

Relationships

Closes #514

Copilot AI review requested due to automatic review settings July 7, 2026 19:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades @confluentinc/kafka-javascript to a newer release and removes several local TypeScript/runtime-shape workarounds that were compensating for upstream type mismatches now resolved in the dependency.

Changes:

  • Upgraded @confluentinc/kafka-javascript to ^1.10.0 and updated the lockfile accordingly.
  • Removed the fetchTopicMetadata() response normalizer and updated call sites/tests to consume the now-correctly-typed ITopicMetadata[] directly.
  • Simplified consumer-group assignment and offset-error handling now that upstream types better match runtime behavior, and updated tests to match the new shapes.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/confluent/tools/handlers/kafka/topic-metadata.ts Removed the now-unneeded fetchTopicMetadata response normalizer helper.
src/confluent/tools/handlers/kafka/topic-metadata.test.ts Removed tests that exclusively validated the deleted normalizer.
src/confluent/tools/handlers/kafka/get-consumer-group-lag-handler.ts Consumes fetchTopicMetadata() as an array directly; tightens FetchOffsetsPartition.error check to strict null.
src/confluent/tools/handlers/kafka/get-consumer-group-lag-handler.test.ts Updates fixtures/mocks to match the newer fetchTopicMetadata and FetchOffsetsPartition.error shapes.
src/confluent/tools/handlers/kafka/describe-consumer-group-handler.ts Simplifies assignment extraction to member.assignment.topicPartitions.map(...) per updated upstream typing.
src/confluent/tools/handlers/kafka/describe-consumer-group-handler.test.ts Updates member fixtures to use { topicPartitions: [...] } assignment wrapper consistently.
src/confluent/tools/handlers/kafka/consume-kafka-messages-handler.ts Removes fetchTopicMetadata normalization usage; consumes the array return directly.
src/confluent/tools/handlers/kafka/consume-kafka-messages-handler.test.ts Drops casting/workaround in the metadata fixture helper, aligning with the updated return type.
package.json Bumps @confluentinc/kafka-javascript dependency spec to ^1.10.0.
pnpm-lock.yaml Lockfile update reflecting the dependency bump and new transitive versions.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

@sonarqube-confluent

Copy link
Copy Markdown

@jlrobins James Robinson (jlrobins) marked this pull request as ready for review July 7, 2026 19:51
@jlrobins James Robinson (jlrobins) requested review from a team as code owners July 7, 2026 19:51
@jlrobins James Robinson (jlrobins) enabled auto-merge (squash) July 7, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove workarounds and tests over workarounds when the next confluent-kafka-javascript release happens

2 participants