Forums

Anyone help a brother out?

I've got the following error and I just can't for the life of me figure it out...

Any code god care to show me the way? :P

2018-01-17 20:42:03,813: Error running WSGI application
2018-01-17 20:42:03,818: TypeError: TypeError("'NoneType' object has no attribute '__getitem__'",) is not JSON serializable
2018-01-17 20:42:03,818:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
2018-01-17 20:42:03,818:     return self.wsgi_app(environ, start_response)
2018-01-17 20:42:03,819: 
2018-01-17 20:42:03,819:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
2018-01-17 20:42:03,819:     response = self.make_response(self.handle_exception(e))
2018-01-17 20:42:03,819: 
2018-01-17 20:42:03,820:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
2018-01-17 20:42:03,820:     reraise(exc_type, exc_value, tb)
2018-01-17 20:42:03,820: 
2018-01-17 20:42:03,820:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
2018-01-17 20:42:03,821:     response = self.full_dispatch_request()
2018-01-17 20:42:03,821: 
2018-01-17 20:42:03,821:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/app.py", line 1479, in full_dispatch_request
2018-01-17 20:42:03,821:     response = self.process_response(response)
2018-01-17 20:42:03,821: 
2018-01-17 20:42:03,822:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/app.py", line 1693, in process_response
2018-01-17 20:42:03,822:     self.save_session(ctx.session, response)
2018-01-17 20:42:03,822: 
2018-01-17 20:42:03,822:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/app.py", line 837, in save_session
2018-01-17 20:42:03,822:     return self.session_interface.save_session(self, session, response)
2018-01-17 20:42:03,823: 
2018-01-17 20:42:03,823:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/sessions.py", line 326, in save_session
2018-01-17 20:42:03,823:     val = self.get_signing_serializer(app).dumps(dict(session))
2018-01-17 20:42:03,823: 
2018-01-17 20:42:03,823:   File "/home/graingerkid/.local/lib/python2.7/site-packages/itsdangerous.py", line 565, in dumps
2018-01-17 20:42:03,824:     payload = want_bytes(self.dump_payload(obj))
2018-01-17 20:42:03,824: 
2018-01-17 20:42:03,824:   File "/home/graingerkid/.local/lib/python2.7/site-packages/itsdangerous.py", line 847, in dump_payload
2018-01-17 20:42:03,824:     json = super(URLSafeSerializerMixin, self).dump_payload(obj)
2018-01-17 20:42:03,824: 
2018-01-17 20:42:03,825:   File "/home/graingerkid/.local/lib/python2.7/site-packages/itsdangerous.py", line 550, in dump_payload
2018-01-17 20:42:03,825:     return want_bytes(self.serializer.dumps(obj))
2018-01-17 20:42:03,826: 
2018-01-17 20:42:03,826:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/sessions.py", line 85, in dumps
2018-01-17 20:42:03,826:     return json.dumps(_tag(value), separators=(',', ':'))
2018-01-17 20:42:03,826: 
2018-01-17 20:42:03,826:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/json.py", line 126, in dumps
2018-01-17 20:42:03,827:     rv = _json.dumps(obj, **kwargs)
2018-01-17 20:42:03,827: 
2018-01-17 20:42:03,827:   File "/home/graingerkid/.local/lib/python2.7/site-packages/simplejson/__init__.py", line 397, in dumps
2018-01-17 20:42:03,827:     **kw).encode(obj)
2018-01-17 20:42:03,827: 
2018-01-17 20:42:03,828:   File "/home/graingerkid/.local/lib/python2.7/site-packages/simplejson/encoder.py", line 275, in encode
2018-01-17 20:42:03,828:     chunks = self.iterencode(o, _one_shot=True)
2018-01-17 20:42:03,828: 
2018-01-17 20:42:03,828:   File "/home/graingerkid/.local/lib/python2.7/site-packages/simplejson/encoder.py", line 357, in iterencode
2018-01-17 20:42:03,828:     return _iterencode(o, 0)
2018-01-17 20:42:03,829: 
2018-01-17 20:42:03,829:   File "/home/graingerkid/.local/lib/python2.7/site-packages/flask/json.py", line 83, in default
2018-01-17 20:42:03,829:     return _json.JSONEncoder.default(self, o)
2018-01-17 20:42:03,829: 
2018-01-17 20:42:03,829:   File "/home/graingerkid/.local/lib/python2.7/site-packages/simplejson/encoder.py", line 252, in default
2018-01-17 20:42:03,830:     raise TypeError(repr(o) + " is not JSON serializable")

Everything in my route is wrapped in exceptions so I'm at a loss.

Hmm, that's hard to debug without seeing the code. At the risk of telling you something you already know, the error specifically means that you're trying to JSON-serialize an exception; something somewhere in your code is doing something like foo[x], and foo is set to None, hence the original exception, and then something somewhere else (maybe part of Flask) is trying to JSONify exceptions that are raised by the code.

Is there any chance you could share the code of the view that's triggering the error? If it's not something you'd like to make public, you can send it to us via the "Send feedback" link.