Skip to content

Short Discussions don't work with JSON payloads #73

@deldesir

Description

@deldesir

The error raises wether I communicate to the bot by invoking the interactive mode with the --json (or -j) flag or running flask app accessible via a JSON endpoint.


ERROR in app: Exception on /reply [POST]
Traceback (most recent call last):
  File "/home/botmaster/.virtualenvs/a004/local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/botmaster/.virtualenvs/a004/local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/botmaster/.virtualenvs/a004/local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/botmaster/.virtualenvs/a004/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/botmaster/.virtualenvs/a004/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "server.py", line 54, in reply
    reply = bot.reply(username, message)
  File "../../rivescript/rivescript.py", line 999, in reply
    return self._brain.reply(user, msg, errors_as_replies)
  File "../../rivescript/brain.py", line 69, in reply
    reply = self._getreply(user, msg, ignore_object_errors=errors_as_replies)
  File "../../rivescript/brain.py", line 301, in _getreply
    self.master.set_uservar(user, "__lastmatch__", matchedTrigger)
  File "../../rivescript/rivescript.py", line 757, in set_uservar
    self._session.set(user, {name: value})
  File "/home/botmaster/bot/eg/json-server/redis_storage.py", line 38, in set
    self.c.set(self.key(username), json.dumps(data))
  File "/usr/lib/python2.7/json/__init__.py", line 244, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <_sre.SRE_Pattern object at 0xb6b1ee58> is not JSON serializable

Edit/fixed the post formatting. --Kirsle

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions