StackStorm-Exchange / stackstorm-kafka

Integration pack for Apache Kafka message broker
https://exchange.stackstorm.org/
Apache License 2.0
5 stars 11 forks source link

Bug: ProduceResponse' object has no attribute '__dict__' #6

Closed surfer190 closed 5 years ago

surfer190 commented 5 years ago

When producing a message on kafka the ProduceResponse object has no __dict__ attribute.

The environment:

[cent@st2 actions]$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core) 
[cent@st2 actions]$ st2 --version
st2 3.0.0, on Python 2.7.5

The command and error:

[cent@st2 actions]$ st2 run kafka.produce topic='test' message='Hello from stackstorm'
.
id: 5cd40e9652364c11e30049c5
status: failed
parameters: 
  message: Hello from stackstorm
  topic: test
result: 
  exit_code: 1
  result: None
  stderr: "Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/python_runner/python_action_wrapper.py", line 334, in <module>
    obj.run()
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/python_runner/python_action_wrapper.py", line 193, in run
    output = action.run(**self._parameters)
  File "/opt/stackstorm/packs/kafka/actions/produce.py", line 45, in run
    return result[0].__dict__
AttributeError: 'ProduceResponse' object has no attribute '__dict__'
No handlers could be found for logger "kafka.producer"
"
  stdout: ''
arm4b commented 5 years ago

Thanks for the report!

It comes from https://github.com/StackStorm-Exchange/stackstorm-kafka/blob/a1e397eb8d945d2d763c988febb52c1296a5a100/actions/produce.py#L44-L45

I'd suggest to debug what is the actual value of the result var in there and if it's empty add a workaround. Fixes are very welcome.

surfer190 commented 5 years ago

@armab I managed to write it out: stdout: 'ProduceResponse(topic=''test'', partition=0, error=0, offset=45)

I want to open a python debugger but it doesn't stay open...