From 402d6584ba401befae738737d1c203a26d261525 Mon Sep 17 00:00:00 2001 From: anti Date: Thu, 30 Apr 2026 22:09:51 -0400 Subject: [PATCH] fix(topology_store): use sqlite3.Row for named column access in current() Row unpacking by positional index breaks silently on schema changes. row_factory = sqlite3.Row gives named access with zero overhead. --- decnet/agent/topology_store.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/decnet/agent/topology_store.py b/decnet/agent/topology_store.py index 7112307e..86427597 100644 --- a/decnet/agent/topology_store.py +++ b/decnet/agent/topology_store.py @@ -63,6 +63,7 @@ class TopologyStore: # The agent is single-process, so there's no real contention — # sqlite's own connection lock is enough. self._conn = sqlite3.connect(str(db_path), check_same_thread=False) + self._conn.row_factory = sqlite3.Row self._conn.execute( "CREATE TABLE IF NOT EXISTS applied_topology (" " topology_id TEXT PRIMARY KEY," @@ -84,11 +85,11 @@ class TopologyStore: if row is None: return None return AppliedRow( - topology_id=row[0], - applied_version_hash=row[1], - hydrated=json.loads(row[2]), - applied_at=int(row[3]), - last_error=row[4], + topology_id=row["topology_id"], + applied_version_hash=row["applied_version_hash"], + hydrated=json.loads(row["hydrated_blob_json"]), + applied_at=int(row["applied_at"]), + last_error=row["last_error"], ) # ---------------------------------------------------------------- writes