runwayml / model-sdk

💥🐍 Runway Model SDK: port your own machine learning models to Runway

Home Page:https://sdk.runwayml.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

POSTing JSON without specifying content-type header throws 500

brannondorsey opened this issue · comments

python model.py
Starting model server at http://0.0.0.0:8000...
curl -H "content-type: application/json" -d '{"some_option": 1}' http://0.0.0.0:8000 # 200 OK
curl -d '{"some_option": 1}' http://0.0.0.0:8000 # 500 server error

POSTing JSON without explicitly setting a Content-Type: application/json causes the request to bomb with the following stack trace.

127.0.0.1 - - [2019-04-08 14:27:14] "POST /setup HTTP/1.1" 200 165 0.001232
[2019-04-08 14:27:25,617] ERROR in app: Exception on /setup [POST]
Traceback (most recent call last):
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask_Cors-3.0.7-py3.7.egg/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/_compat.py", line 35, in reraise
    raise value
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/runway_python-0.0.55-py3.7.egg/runway/model.py", line 44, in setup_route
    self.setup_model(opts)
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/runway_python-0.0.55-py3.7.egg/runway/model.py", line 152, in setup_model
    if name in opts:
TypeError: argument of type 'NoneType' is not iterable

We should either give a 400 bad request error that describes the request must include this specific content-type header, or we could sniff the payload and if it parses as JSON let it by.