toconnell / kdm-manager

An interactive campaign manager for the game "Monster", by Kingdom Death. Development blog and release notes at https://blog.kdm-manager.com This project has no affiliation with Kingdom Death and is a totally independent, fan-maintained project.
http://kdm-manager.com
Other
26 stars 11 forks source link

Legacy webapp fails to initialize settlement; boots users #502

Closed toconnell closed 6 years ago

toconnell commented 6 years ago

Legacy webapp crash email:

[5a1cd6c98740d9723e6441fa] was logged out of the webapp instance on ubuntu-trusty-1 due to a render failure at 2018-05-15 02:48:00.668941.

 The traceback from the exception was this:
Traceback (most recent call last):
File "/home/toconnell/kdm-manager/v1/session.py", line 37, in wrapper
 return func(self, *args, **kwargs)
File "/home/toconnell/kdm-manager/v1/session.py", line 553, in current_view_html
 self.set_current_settlement()
File "/home/toconnell/kdm-manager/v1/session.py", line 330, in set_current_settlement
 self.Settlement = assets.Settlement(settlement_id=s_id, session_object=self)
File "/home/toconnell/kdm-manager/v1/assets.py", line 633, in __init__
 self.set_settlement(ObjectId(settlement_id))
File "/home/toconnell/kdm-manager/v1/assets.py", line 653, in set_settlement
 raise Exception("Could not initialize requested settlement %s!" % s_id)
Exception: Could not initialize requested settlement 5afa4a5f8740d928885aeea8!

assets.Settlement.init() calls _setsettlement(), which sometimes bombs. Here's that method:

646     def set_settlement(self, s_id, update_mins=False):
647         """ Sets self.settlement. """
648
649         self.settlement = mdb.settlements.find_one({"_id": s_id})
650
651         if self.settlement is None:
652             self.logger.error("[%s] failed to initialize settlement _id: %s" % (self.User, s_id))
653             raise Exception("Could not initialize requested settlement %s!" % s_id)

I've gotten three of these since the last release, so there's something going on here.

It appears to be affecting new and older users: last night's user is 168 days old and the one from the 13th (two days ago) was brand new at the time.

Kind of scratching my head here.

toconnell commented 6 years ago

Something's going on where the asset ID being requested is like...not an OID and is getting coerced to it. The actual OID is in the params, but for some reason, session.py appears to be losing the plot somewhere.

Le sigh.

toconnell commented 6 years ago

Turns out that session.Session.change_current_view() was only setting self.session['current_settlement'] for the 'view_campaign' view, i.e. not for 'view_settlement'.

The result was that we were duck-typing None to an OID and thus getting an invalid settlement ID, etc.

This legacy webapp really...needs to go away.

Anyway, fix will be deployed in the next release.