Check topic_partitions in list/alter_consumer_group_offsets() #2443
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 488 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.370
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2443"
general
weight: 0.35
pylaterreur
What
----
The C
list_consumer_group_offsets()andalter_consumer_group_offsets()ignored the result of reading thetopic_partitionsattribute of the request, and of converting it withpy_to_c_parts().AdminClientvalidates the request first, but its checks acceptlistandTopicPartitionsubclasses, which the C methods reject. So the C methods crashed throughAdminClientwith such subclasses, as well as when called directly or given a request changed after that validation:topic_partitionscame back as NULL, with theAttributeErrorstill set. Atopic_partitionsthat is not exactly a list, such as alistsubclass, made the read fail and left the pointer NULL. Both went topy_to_c_parts(), which segfaults on NULL.TopicPartition, such as aTopicPartitionsubclass,py_to_c_parts()failed and returned NULL.list_consumer_group_offsets()then sent a request for all the partitions of the group and returned with theTypeErrorset, which Python reports asSystemError: ... returned a result with an exception set.alter_consumer_group_offsets()aborted the process on librdkafka's assertiongroup_id && partitionsinrd_kafka_AlterConsumerGroupOffsets_new(), as it did fortopic_partitions=None.PyObject_IsInstance()counted as a match.topic_partitionsis now read as a required attribute, the read and the conversion are checked, an alter request without partitions raisesValueError, asAdminClientdoes, and thePyObject_IsInstance()result is checked. ThelistandTopicPartitionsubclasses now raiseTypeError. Thegroup_idhandling is unchanged: a failed read already ends in theValueErrorfor a missing group name.This is the same kind of problem as #2442 in
alter_user_scram_credentials().Checklist
------------------
- Yes: through
AdminClient,listandTopicPartitionsubclasses crashed the process or raised aSystemError, and now raiseTypeError. CHANGELOG entry under Unreleased.- New
tests/test_admin_group_offsets_requests.pycalls both C methods directly with a valid request and 5 invalid ones, and bothAdminClientmethods with alistsubclass and with aTopicPartitionsubclass, each in a subprocess, since most of them crashed.References
----------
alter_user_scram_credentials().Test & Review
------------
SystemError. With this branch, all 16 pass on both, and passed 20 of 20 runs of the file on each, 3 at a time on one CPU.tests/test_*.pyandtests/concurrency: 653 passed and 5 skipped on 3.11. On 3.14t, 492 passed, 7 skipped and 2 failed, plus 3 collection errors, all from my environment: the 2tests/test_unasync.pytests needisort, andtests/test_log.py,tests/test_Producer.pyandtests/test_serializer_error.pyneedurllib3, which my 3.14t environment lacks.tests/test_kafka_error.py::test_kafkaError_unknown_errorwas deselected there: with that environment's pluggy it stops the whole run, which https://github.com/confluentinc/confluent-kafka-python/pull/2444 fixes.tools/style-format.shandflake8pass on the test file. clang-format 18.1.8 and 20.1.8 report no new differences inAdmin.c.🤖 Generated with Claude Code
https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN