Skip to content

The agent that grows with you

fix(cron): a parseable non-dict Bot Chat receipt no longer wedges the deferred drain

beardthelion8235afad5df1
diff --git a/cron/bot_chat_delivery.py b/cron/bot_chat_delivery.py
index cdb6a2f7020..d743353a0ac 100644
--- a/cron/bot_chat_delivery.py
+++ b/cron/bot_chat_delivery.py
@@ -37,6 +37,8 @@ def _records(root: Path) -> list[tuple[Path, dict]]:
for path in root.glob("*.json"):
try:
record = json.loads(path.read_text(encoding="utf-8"))
+ if not isinstance(record, dict):
+ raise ValueError(f"expected a JSON object, got {type(record).__name__}")
except (OSError, ValueError) as exc: # ValueError: corrupt JSON and invalid UTF-8 alike
# Keep damaged or unreadable receipts as evidence; never replay them or block peers
# (same rule as tools/bot_live_delivery.py::_scan_read — one bad file must not wedge the dir).
@@ -94,7 +96,7 @@ def _drain(root: Path) -> None:
for path, _ in records:
with _FileLock(root / ".lock"):
record = json.loads(path.read_text(encoding="utf-8"))
- if record["status"] != "queued":
+ if not isinstance(record, dict) or record["status"] != "queued":
continue
home = Path(record["home"])
# A failure notice queued before the target profile opted out is settled as