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

Survivor.set_status_flag() 'backoff_to_name' failure #75

Closed toconnell closed 9 months ago

toconnell commented 9 months ago

User OID: 56a76cb6421aa909ee873ca9 Method: POST URL: http://api.kdm-manager.com/survivor/set_status_flag/607314e483d1e3c9ce94fd49 JSON: {'flag': 'departing', 'serialize_on_response': True}

Traceback (most recent call last):
File "/home/toconnell/kdm-manager-api/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
 rv = self.dispatch_request()
File "/home/toconnell/kdm-manager-api/venv/lib/python3.8/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 57, in wrapped_function
 resp = flask.make_response(func(*args, **kwargs))
File "/home/toconnell/kdm-manager-api/app/routes.py", line 510, in collection_action
 asset_object = models.get_user_asset(collection, asset_id)
File "/home/toconnell/kdm-manager-api/app/models/__init__.py", line 100, in get_user_asset
 return survivors.Survivor(
File "/home/toconnell/kdm-manager-api/app/models/survivors/_survivor.py", line 240, in __init__
 self.normalize()
File "/home/toconnell/kdm-manager-api/app/models/survivors/_survivor.py", line 592, in normalize
 self.save()
File "/home/toconnell/kdm-manager-api/app/models/survivors/_survivor.py", line 523, in save
 self._validate_weapon_proficiency_type()
File "/home/toconnell/kdm-manager-api/app/models/survivors/_survivor.py", line 2977, in _validate_weapon_proficiency_type
 wp_dict = self.Settlement.WeaponProficiency.get_asset(wp_handle)
File "/home/toconnell/kdm-manager-api/app/assets/_collection.py", line 502, in get_asset
 if not backoff_to_name:
NameError: name 'backoff_to_name' is not defined
toconnell commented 9 months ago

Looks like this got missed in the grand scheme to deprecate name lookups for assets.

Fixed in the next release:

         # if the asset is still None, we want to raise an expception
         if asset is None and raise_exception_if_not_found:
-            if not backoff_to_name:
-                curframe = inspect.currentframe()
-                calframe = inspect.getouterframes(curframe, 2)
-                caller_function = calframe[1][3]
-                msg = (
-                    "%s() -> get_asset() "
-                    "The handle '%s' could not be found in %s!"
-                ) % (caller_function, handle, self.get_handles() )
-                self.logger.error(msg)
-            elif backoff_to_name:
-                msg = "After backoff to name lookup, asset handle '%s' is not\
-                in %s and could not be retrieved." % (handle, self.get_names())
-                self.logger.error(msg)
+            curframe = inspect.currentframe()
+            calframe = inspect.getouterframes(curframe, 2)
+            caller_function = calframe[1][3]
+            msg = (
+                "%s() -> get_asset() "
+                "The handle '%s' could not be found in %s!"
+            ) % (caller_function, handle, self.get_handles() )
+            self.logger.error(msg)
             raise utils.InvalidUsage(msg, status_code=500)