aiokafka icon indicating copy to clipboard operation
aiokafka copied to clipboard

"'NoneType' object is not callable" if lz4 compression enabled on server but lib not installed

Open mstump opened this issue 6 years ago • 2 comments

The library errors with a cryptic message if lz4 compression is enabled on the Kafka cluster but the corresponding Python library is not installed on the consumer/broker. It took a while to diagnose so I wanted to advocate for a better error message. Worst case I wanted to log the stack trace so it's indexed by Google and resolvable by future users.

[2018-12-17 18:16:55,621: ERROR]: [^--Consumer]: Drain messages raised: TypeError("'NoneType' object is not callable")
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/faust/transport/consumer.py", line 501, in _drain_messages
    async for tp, message in ait:
  File "/usr/local/lib/python3.7/site-packages/faust/transport/drivers/aiokafka.py", line 322, in getmany
    timeout=timeout,
  File "/usr/local/lib/python3.7/site-packages/faust/transport/drivers/aiokafka.py", line 695, in getmany
    timeout=timeout,
  File "/usr/local/lib/python3.7/site-packages/mode/threads.py", line 339, in call_thread
    result = await promise
  File "/usr/local/lib/python3.7/site-packages/mode/threads.py", line 284, in _process_enqueued
    result = await maybe_async(method(*args, **kwargs))
  File "/usr/local/lib/python3.7/site-packages/mode/utils/futures.py", line 109, in maybe_async
    return await res
  File "/usr/local/lib/python3.7/site-packages/aiokafka/consumer/fetcher.py", line 867, in fetched_records
    records = res_or_error.getall(max_records)
  File "/usr/local/lib/python3.7/site-packages/aiokafka/consumer/fetcher.py", line 133, in getall
    for msg in next_batch_iter:
  File "/usr/local/lib/python3.7/site-packages/aiokafka/consumer/fetcher.py", line 985, in _unpack_records
    for record in next_batch:
  File "aiokafka/record/_legacy_records.pyx", line 238, in __iter__
  File "aiokafka/record/_legacy_records.pyx", line 136, in aiokafka.record._legacy_records._LegacyRecordBatchCython._decompress
TypeError: 'NoneType' object is not callable

mstump avatar Dec 17 '18 19:12 mstump

I particularly dislike this:

except ImportError:
    lz4 = None

I think it should be either logged at least as a DEBUG message if handled like this or If you don't solve at all, the error would be more obvious than generic None type error

trnkatomas avatar Sep 09 '20 15:09 trnkatomas

Running this command can solve pip install lz4

wc571498244 avatar Jul 01 '22 03:07 wc571498244