Search code examples
faustredpandaaiokafka

Faust-streaming Error in hello_world demo code: object has no attribute 'build_request_header'


Im familiarizing myself with kafka via faust-streaming. I created a python 3.10 env, and a redpanda cluster on localhost:9092. The code I used is the hello world demo presented by the faust-streaming documentation. https://faust-streaming.github.io/faust/playbooks/quickstart.html

import faust

app = faust.App(
    'hello-world',
    broker='kafka://localhost:9092',
    value_serializer='raw',
)

greetings_topic = app.topic('greetings')

@app.agent(greetings_topic)
async def greet(greetings):
    async for greeting in greetings:
        print(greeting)

When I run the application with "faust -A hello_world worker -l info" I recieve the error:

[^Worker]: Error: AttributeError("'CreateTopicsRequest_v1' object has no attribute 'build_request_header'.

I checked if the cluster might be the issue, but an aiokafka setup with a producer/consumer aimed at localhost:9092 seems to run smoothly. Since I cant find any mention of this issue, I'm hoping anyone here can help me get faust-streaming running.


Solution

  • Unfortunate timing is all.

    This is a dependency management issue (on faust-streaming's part). Their package (faust-streaming at 0.11.0) allows for any version of aiokafka >= 0.9.0, yet aiokafka just released 0.11.0 two weeks ago.

    Just add an upper-limit to your environment to prevent the use of the latest release of aiokafka until faust-streaming is updated.

    # Update your requirements file
    echo 'aiokafka>=0.9.0,<0.11.0' >> requirements.txt
    
    # Or, just install aiokafka with a version range
    pip install 'aiokafka>=0.9.0,<0.11.0'
    
    # Or, if you're using poetry
    poetry add 'aiokafka>=0.9.0,<0.11.0'
    

    Edit: I looked on github and found an issue for it which you can track for a resolution: https://github.com/faust-streaming/faust/issues/633#issue-2406150814