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:
Matt Johnson (via Claude) 2026-06-07 06:57:11 +00:00
commit fc78f26c82

View file

@ -70,10 +70,14 @@ class Grouper:
try:
import json
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(
"INSERT OR REPLACE INTO grouper_held(group_key, event_json, "
"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:
self._logger.exception("grouper: persist failed key=%s", group_key)