Description
The Kafka transport in commlib-py 0.13.1 has broken logger().info() calls that raise TypeError: not all arguments converted during string formatting. This crashes both the subscriber thread (in _on_assign) and the publisher delivery callback (_on_delivery), making Kafka pub/sub non-functional.
Affected Code
commlib/transports/kafka.py, line ~278 (_on_assign):
self.logger().info("Assignment:", partitions)
Should be:
self.logger().info("Assignment: %s", partitions)
commlib/transports/kafka.py, line ~184 (_on_delivery):
self.logger().info("Published on %s, partition", msg.topic(), f"{msg.partition()}")
Should be:
self.logger().info("Published on %s, partition %s", msg.topic(), msg.partition())
Impact
- The subscriber's
_on_assign callback crashes, killing the consumer thread entirely — no messages are ever received.
- The publisher's
_on_delivery callback crashes on producer.poll(0), raising an unhandled exception.
Reproduction
from commlib.transports.kafka import ConnectionParameters, Subscriber, Publisher
import time
conn = ConnectionParameters(host="localhost", port=9092)
pub = Publisher(topic="test.topic", conn_params=conn)
pub.run()
time.sleep(1)
received = []
sub = Subscriber(
topic="test.topic",
on_message=lambda msg: received.append(msg),
conn_params=ConnectionParameters(host="localhost", port=9092, group="test-group"),
)
sub.run()
time.sleep(2)
pub.publish({"key": "value"}) # Triggers _on_delivery crash
time.sleep(3)
print(f"Received: {len(received)}") # Always 0
Traceback
Exception in thread Thread-1 (run_forever):
File "commlib/transports/kafka.py", line 278, in _on_assign
self.logger().info("Assignment:", partitions)
File "/usr/local/lib/python3.12/logging/__init__.py", line 392, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Environment
- commlib-py: 0.13.1
- confluent-kafka: 2.13.2
- Python: 3.12
- Kafka: apache/kafka 3.9.0 (KRaft mode)
Suggested Fix
Replace the two broken logging calls with correct %s-style format strings, as shown above.
Description
The Kafka transport in
commlib-py 0.13.1has brokenlogger().info()calls that raiseTypeError: not all arguments converted during string formatting. This crashes both the subscriber thread (in_on_assign) and the publisher delivery callback (_on_delivery), making Kafka pub/sub non-functional.Affected Code
commlib/transports/kafka.py, line ~278 (_on_assign):Should be:
commlib/transports/kafka.py, line ~184 (_on_delivery):Should be:
Impact
_on_assigncallback crashes, killing the consumer thread entirely — no messages are ever received._on_deliverycallback crashes onproducer.poll(0), raising an unhandled exception.Reproduction
Traceback
Environment
Suggested Fix
Replace the two broken logging calls with correct
%s-style format strings, as shown above.