mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-06-11 01:14:45 +02:00
fix(grouper): strip non-serializable values before persisting held events
event.data can contain callables and internal _on_ callbacks that cause json.dumps to fail with TypeError. Filter these out before serializing to SQLite. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3b12be2242
commit
fc78f26c82
1 changed files with 5 additions and 1 deletions
|
|
@ -70,10 +70,14 @@ class Grouper:
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
from meshai.persistence import get_db
|
from meshai.persistence import get_db
|
||||||
|
d = event.to_dict()
|
||||||
|
d["data"] = {k: v for k, v in d.get("data", {}).items()
|
||||||
|
if not callable(v) and not k.startswith("_on_")}
|
||||||
|
event_json = json.dumps(d)
|
||||||
get_db().execute(
|
get_db().execute(
|
||||||
"INSERT OR REPLACE INTO grouper_held(group_key, event_json, "
|
"INSERT OR REPLACE INTO grouper_held(group_key, event_json, "
|
||||||
"hold_until_at, updated_at) VALUES (?,?,?,?)",
|
"hold_until_at, updated_at) VALUES (?,?,?,?)",
|
||||||
(group_key, json.dumps(event.to_dict()), hold_until, self._now()),
|
(group_key, event_json, hold_until, self._now()),
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
self._logger.exception("grouper: persist failed key=%s", group_key)
|
self._logger.exception("grouper: persist failed key=%s", group_key)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue