Skip to content

Fix KeyError: endpoint_type in describe_cluster against DescribeCluster v0 brokers - #3204

Open
A2wkiller wants to merge 1 commit into
dpkp:masterfrom
A2wkiller:describe-cluster-v0-endpoint-type
Open

A2wkiller wants to merge 1 commit into
dpkp:masterfrom
A2wkiller:describe-cluster-v0-endpoint-type

Conversation

@A2wkiller

Copy link
Copy Markdown

Summary

Fixes #3203. Since #3053, KafkaAdminClient.describe_cluster() pops endpoint_type unconditionally from the DescribeCluster response. endpoint_type was only added to the response schema in v1 (KIP-919), so against brokers that support DescribeCluster at v0 only — Apache Kafka 2.8 through 3.6, and Kafka-compatible brokers implementing only v0 — the pop raises KeyError: 'endpoint_type'.

The pop now defaults to None when the key is absent, matching how throttle_time_ms is already handled on the line below.

Tests

  • New test_describe_cluster_v0_response: parametrize the mock broker at (3, 6), which negotiates DescribeCluster v0 (no endpoint_type in the response). Fails on current code with the reported KeyError, passes with this change.
  • test/admin/ module: 204 passed. Full unit suite: 2730 passed, 1 pre-existing environment failure (test_crc32c[None], missing crc32c library — fails identically on the clean tree), 30 skipped.

Disclosure: this patch was prepared with AI assistance and reviewed/tested by me.

Copilot AI balanced review requested due to automatic review settings November 22, 2026 05:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the change addressing DescribeCluster v0 compatibility.

No open issues 🎉

What changed in this PR

Fixes #3203 by allowing KafkaAdminClient.describe_cluster() to handle DescribeCluster v0 responses, which omit endpoint_type. This restores compatibility with Kafka 2.8–3.6 and compatible v0-only brokers.

Changes:

  • Safely remove endpoint_type only when present in the response.
  • Add a regression test using a mock Kafka 3.6 broker to verify successful cluster metadata retrieval.
File Description
test/​admin/​test_admin_cluster.py Adds regression coverage for DescribeCluster v0 responses.
kafka/​admin/​_cluster.py Defaults the endpoint_type removal to None, preventing a KeyError.

Review effort: Balanced

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.

KafkaAdminClient.describe_cluster() raises KeyError: 'endpoint_type' on brokers that only support DescribeCluster v0

2 participants