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

/game_asset/expansion request fails #76

Closed toconnell closed 7 months ago

toconnell commented 10 months ago

User OID: 666 Method: GET URL: http://api.kdm-manager.com/game_asset/expansion JSON: None

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 275, in lookup_asset
 return assets.get_game_asset(asset_type)
File "/home/toconnell/kdm-manager-api/app/utils/__init__.py", line 331, in not_timed
 return method(*args, **kwargs)
File "/home/toconnell/kdm-manager-api/app/assets/__init__.py", line 45, in get_game_asset
 game_asset = getattr(KingdomDeath, collection_name)
AttributeError: module 'app.assets.kingdom_death' has no attribute 'expansion'

This seems like it might be significant less in terms of the response (which should probably be a 404, so we'll fix that here), but more in terms of ...which application or view or whatever is trying to pull expansion assets this way?

toconnell commented 10 months ago

Fixed the response:

diff --git a/app/assets/__init__.py b/app/assets/__init__.py
index d4f18ec..8f51de7 100644
--- a/app/assets/__init__.py
+++ b/app/assets/__init__.py
@@ -36,13 +36,16 @@ from app.models import settlements, survivors, users
 @utils.metered
 def get_game_asset(collection_name, return_type=flask.Response):
     """ Formerly a part of the (deprecated) request_broker.py module, this
-    method imports an asset type, alls its Assets() method and then returns
+    method imports an asset type, calls its Assets() method and then returns
     its request_response() method.

     This could honestly go back into routes.py at this point.
     """

-    game_asset = getattr(KingdomDeath, collection_name)
+    game_asset = getattr(KingdomDeath, collection_name, None)
+    if game_asset is None:
+        return utils.HTTP_404
+