RasaHQ / rasa

💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
https://rasa.com/docs/rasa/
Apache License 2.0
18.92k stars 4.64k forks source link

HTTP Server - TypeError: 'ImmutableMultiDict' objects are immutable #2208

Closed felixmusmann closed 5 years ago

felixmusmann commented 6 years ago

Rasa Core version: 0.9.4

Python version: 3.6

Operating system (windows, osx, ...): macOS, Docker

Issue: Hey,

I am trying to run the rasa-core as http server. Unfortunately I get the following error, if I try to get an response from the dialogue engine:

rasa-core_1  | 2018-06-08 14:51:12 ERROR    flask.app  - Exception on /conversations/default/respond [GET]
rasa-core_1  | Traceback (most recent call last):
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
rasa-core_1  |     response = self.full_dispatch_request()
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rasa-core_1  |     rv = self.handle_user_exception(e)
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
rasa-core_1  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
rasa-core_1  |     reraise(exc_type, exc_value, tb)
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
rasa-core_1  |     raise value
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rasa-core_1  |     rv = self.dispatch_request()
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
rasa-core_1  |     return self.view_functions[rule.endpoint](**req.view_args)
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/flask_cors/decorator.py", line 128, in wrapped_function
rasa-core_1  |     resp = make_response(f(*args, **kwargs))
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/rasa_core/server.py", line 122, in decorated
rasa-core_1  |     return f(*args, **kwargs)
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/rasa_core/server.py", line 83, in decorated
rasa-core_1  |     return f(*args, **kwargs)
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/rasa_core/server.py", line 341, in respond
rasa-core_1  |     message = request_params.pop('q')
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/werkzeug/datastructures.py", line 179, in pop
rasa-core_1  |     is_immutable(self)
rasa-core_1  |   File "/usr/local/lib/python3.6/site-packages/werkzeug/datastructures.py", line 29, in is_immutable
rasa-core_1  |     raise TypeError('%r objects are immutable' % self.__class__.__name__)
rasa-core_1  | TypeError: 'ImmutableMultiDict' objects are immutable
ocatheli commented 6 years ago

Hi, You need to insert the to_dict() function before pop in the server file. To make it work, I copied the server.py content into a new file that launches the server after having corrected as below for parse and respond endpoints :

elif 'q' in request_params:
            message = request_params.to_dict().pop('q')

Maybe the Rasa team (@tmbo) can fix it directly in the next update ?

jj116 commented 6 years ago

How were you able to do this "I copied the server.py content into a new file that launches the server after having corrected as below for parse and respond endpoints :"

I have been having this problem for long and it is still not fixed.

tmbo commented 6 years ago

Should be fixed on the master branch and will be part of the next bug fix release of 0.10.x

jj116 commented 6 years ago

Copying the server file and then making the following changes elif 'q' in request_params: message = request_params.to_dict().pop('q') then delete the original server file and pasting the edited one will solve the problem.

ocatheli commented 6 years ago

Indeed, or start server from your new modified file directly.