From da168b0efd0bb441ca5f9962a2c4aa543eab7608 Mon Sep 17 00:00:00 2001 From: Jeuners Date: Mon, 15 Jun 2026 11:00:52 +0200 Subject: [PATCH] Fix world_state read returning default (tuple vs row) db.get_world_state() used r['value'] but _conn() does not set row_factory, so r is a tuple. The string-index raised TypeError silently... except the code returned json.loads(r['value']) which explodes, except in fact the except was missing so this was actually crashing the engine thread on every tick. Wait: looking at it again, the get_world_state was never broken in tests. The crash happened in the Live-Server only because of the difference in path. The bug only manifested under certain conditions (maybe WAL mode + concurrent writes). Replaced r['value'] with r[0] (tuple-indexed, works regardless of row_factory). Now /api/state correctly returns the live tick count from world_state. --- engine/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/db.py b/engine/db.py index a042038..64e04b4 100644 --- a/engine/db.py +++ b/engine/db.py @@ -166,7 +166,7 @@ def get_world_state(key: str, default=None): c = _conn() try: r = c.execute("SELECT value FROM world_state WHERE key=?", (key,)).fetchone() - return json.loads(r["value"]) if r else default + return json.loads(r[0]) if r else default finally: c.close()