guluc3m / zoe-lib-python

Core de la nueva Zoe (Zoe 2.0)
MIT License
4 stars 0 forks source link

Error processing lists #1

Closed Patataman closed 6 years ago

Patataman commented 6 years ago

Kafka doesn't like lists inside the intents. Example (show method from the shell):

{
    'intent': 'shell.show',
    'payloads': [ what ]
}

Writing in the shell show("pepe") returns the following error (using my zoe-lib):

Dropping message {"intent": "shell.show", "payloads": [{"intent": "shell.show", "payloads": ["pepe"]}]}
zoe-agent-msglog_1  |   File "/usr/local/lib/python3.6/site-packages/zoe/deco.py", line 137, in incoming
zoe-agent-msglog_1  |     result, error = self.dispatch(incoming)
zoe-agent-msglog_1  |   File "/usr/local/lib/python3.6/site-packages/zoe/deco.py", line 162, in dispatch
zoe-agent-msglog_1  |     result = invoker(method, intent)
zoe-agent-msglog_1  |   File "/usr/local/lib/python3.6/site-packages/zoe/deco.py", line 334, in <lambda>
zoe-agent-msglog_1  |     INVOKER = lambda method, intent: method(intent)
zoe-agent-msglog_1  |   File "/code/src/agent.py", line 43, in x
zoe-agent-msglog_1  |     traverse(intent, inner)
zoe-agent-msglog_1  |   File "/code/src/agent.py", line 27, in traverse
zoe-agent-msglog_1  |     traverse(p, inner, depth + 2, color)
zoe-agent-msglog_1  |   File "/code/src/agent.py", line 27, in traverse
zoe-agent-msglog_1  |     traverse(p, inner, depth + 2, color)
zoe-agent-msglog_1  |   File "/code/src/agent.py", line 20, in traverse
zoe-agent-msglog_1  |     value = intent[key]
zoe-agent-msglog_1  | Traceback (most recent call last):
zoe-agent-msglog_1  |   File "/usr/local/lib/python3.6/site-packages/zoe/deco.py", line 137, in incoming
zoe-agent-msglog_1  |     result, error = self.dispatch(incoming)
zoe-agent-msglog_1  |   File "/usr/local/lib/python3.6/site-packages/zoe/deco.py", line 162, in dispatch
zoe-agent-msglog_1  |     result = invoker(method, intent)
zoe-agent-msglog_1  |   File "/usr/local/lib/python3.6/site-packages/zoe/deco.py", line 334, in <lambda>
zoe-agent-msglog_1  |     INVOKER = lambda method, intent: method(intent)
zoe-agent-msglog_1  |   File "/code/src/agent.py", line 43, in x
zoe-agent-msglog_1  |     traverse(intent, inner)
zoe-agent-msglog_1  |   File "/code/src/agent.py", line 27, in traverse
zoe-agent-msglog_1  |     traverse(p, inner, depth + 2, color)
zoe-agent-msglog_1  |   File "/code/src/agent.py", line 27, in traverse
zoe-agent-msglog_1  |     traverse(p, inner, depth + 2, color)
zoe-agent-msglog_1  |   File "/code/src/agent.py", line 20, in traverse
zoe-agent-msglog_1  |     value = intent[key]
zoe-agent-msglog_1  | TypeError: string indices must be integers

Here we can see that there's an error in line dispatch (line 162), also in this method, the variables intent, parent and method had this values:

Selector: <function Raw.<lambda> at 0x7f1e1287ca60>
Intent: {'intent': 'shell.show', 'payloads': [{'intent': 'shell.show', 'payloads': ['pepe']}]}
Parent: None

This seems totally ok, but the problem comes when the inner intent is solved:

Selector: <function Inner.<lambda> at 0x7fd74e7f28c8>
Intent: {'intent': 'shell.show', 'payloads': ['pepe']}
Parent: [{'intent': 'shell.show', 'payloads': ['pepe']}]

Selector seems Ok, Intent too, but the Parent should be the before Intent, right? Not a list with the Intent being solve right now!

voiser commented 6 years ago

It's not Kafka, but the parent lookup algorithm. I've updated it so that parents always point to the parent intent, not to the parent object. Good catch.

https://github.com/guluc3m/zoe-lib-python/blob/master/zoe/tests/intents.py#L123

Please let me know if this solves your issues.