rebuild(migration): validate local legacy cutover
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import json
|
||||
import sqlite3
|
||||
from datetime import datetime, timedelta
|
||||
@@ -147,8 +148,28 @@ def public_job(row: sqlite3.Row) -> dict[str, Any]:
|
||||
result = dict(row)
|
||||
result["source_set"] = json.loads(str(result.pop("source_set_json")))
|
||||
result["payload"] = json.loads(str(result.pop("payload_json")))
|
||||
result["error_message"] = _public_error_message(str(result["error_message"]))
|
||||
return result
|
||||
|
||||
|
||||
def _public_error_message(value: str) -> str:
|
||||
"""Normalize AppError tuples written before structured error storage."""
|
||||
if not value.startswith("("):
|
||||
return value
|
||||
try:
|
||||
legacy = ast.literal_eval(value)
|
||||
except (SyntaxError, ValueError):
|
||||
return value
|
||||
if (
|
||||
isinstance(legacy, tuple)
|
||||
and len(legacy) == 3
|
||||
and isinstance(legacy[0], str)
|
||||
and isinstance(legacy[1], str)
|
||||
and isinstance(legacy[2], int)
|
||||
):
|
||||
return legacy[1]
|
||||
return value
|
||||
|
||||
|
||||
def _json(value: Any) -> str:
|
||||
return json.dumps(value, ensure_ascii=False, separators=(",", ":"), sort_keys=True)
|
||||
|
||||
Reference in New Issue
Block a user