theLaborInVain / kdm-manager-api

The API used by https://kdm-manager.com and related Kingdom Death: Monster utilities.
Other
3 stars 0 forks source link

Survivors: set_constellation() method fails on None #47

Closed toconnell closed 3 years ago

toconnell commented 3 years ago

User OID: 5dee43f965159353a815a48e Method: POST URL: http://api.kdm-manager.com/survivor/set_constellation/5ff2006a33c6092dfd2e6e50 JSON: {'constellation': None, 'serialize_on_response': True}

Traceback (most recent call last):
File "/home/toconnell/kdm-manager-api/venv/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
 rv = self.dispatch_request()
File "/home/toconnell/kdm-manager-api/venv/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
 return self.view_functions[rule.endpoint](**req.view_args)
File "/home/toconnell/kdm-manager-api/app/utils/crossdomain.py", line 56, in wrapped_function
 resp = flask.make_response(func(*args, **kwargs))
File "/home/toconnell/kdm-manager-api/app/routes.py", line 506, in collection_action
 return asset_object.request_response(action)
File "/home/toconnell/kdm-manager-api/app/models/survivors/__init__.py", line 3522, in request_response
 self.set_constellation()
File "/home/toconnell/kdm-manager-api/app/models/survivors/__init__.py", line 2139, in set_constellation
 self.add_game_asset("epithets", "the_%s" % constellation.lower())
AttributeError: 'NoneType' object has no attribute 'lower'
toconnell commented 3 years ago

It shouldn't by possible to set this to a None unless you're posting directly to the API...

toconnell commented 3 years ago

Added a sanity-check for this to help developers (i.e. by bombing out an attempt to set the value to None/null.