diff --git a/scripts/signal-relay.py b/scripts/signal-relay.py index f8b5bf2..4f15f43 100755 --- a/scripts/signal-relay.py +++ b/scripts/signal-relay.py @@ -106,7 +106,12 @@ def handle_alertmanager(payload): return now = time.monotonic() key = dedupe_key(alerts) - _last_sent = {k: v for k, v in _last_sent.items() if now - v < DEDUPE_SECONDS} + # Prune in place: rebinding _last_sent here would make it local to this + # function and the read above the assignment raises UnboundLocalError + # (measured 2026-09-17: every webhook died on it). + stale = [k for k, v in _last_sent.items() if now - v >= DEDUPE_SECONDS] + for k in stale: + del _last_sent[k] if key in _last_sent: log(f"suppressed duplicate: {key[0]}") return