From 526af7097dabdd8cc25918571059a21bd4d0b18a Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Wed, 18 Mar 2026 23:28:51 +0100 Subject: [PATCH] Backfill default keys in DB get_sequence for API responses Ensures the project loader API always returns all expected keys like mode, cfg, etc. even if they were missing from stored data. Co-Authored-By: Claude Opus 4.6 --- db.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/db.py b/db.py index c95f90f..1f32f9c 100644 --- a/db.py +++ b/db.py @@ -5,7 +5,7 @@ import time from pathlib import Path from typing import Any -from utils import load_json, KEY_BATCH_DATA, KEY_HISTORY_TREE +from utils import load_json, DEFAULTS, KEY_BATCH_DATA, KEY_HISTORY_TREE logger = logging.getLogger(__name__) @@ -231,7 +231,10 @@ class ProjectDB: ).fetchone() if not row: return None - return self._migrate_lora_keys(json.loads(row["data"])) + data = json.loads(row["data"]) + for k, v in DEFAULTS.items(): + data.setdefault(k, v) + return self._migrate_lora_keys(data) def list_sequences(self, data_file_id: int) -> list[int]: rows = self.conn.execute(