fix: enforce TTL in MessageDeduplicator + use yaml for gateway --config (#10306, #10216) (#10509)

Two gateway fixes:

1. MessageDeduplicator.is_duplicate() now checks TTL at query time (#10306)

   Previously, is_duplicate() returned True for any previously seen ID
   without checking its age — expired entries were only purged when cache
   size exceeded max_size.  On normal workloads that never overflow, message
   IDs stayed deduplicated forever instead of expiring after the TTL.

   Fix: check `now - timestamp < ttl` before returning True.  Expired
   entries are removed and treated as new messages.

2. Gateway --config flag now uses yaml.safe_load() (#10216)

   The --config CLI flag in gateway/run.py main() used json.load() to
   parse config files.  YAML is the only documented config format and
   every other config loader uses yaml.safe_load().  A YAML config file
   passed via --config would crash with json.JSONDecodeError.

Closes #10306
Closes #10216
This commit is contained in:
Teknium
2026-04-15 13:35:40 -07:00
committed by GitHub
parent af4bf505b3
commit 2edbf15560
3 changed files with 95 additions and 3 deletions

View File

@@ -49,7 +49,10 @@ class MessageDeduplicator:
return False
now = time.time()
if msg_id in self._seen:
return True
if now - self._seen[msg_id] < self._ttl:
return True
# Entry has expired — remove it and treat as new
del self._seen[msg_id]
self._seen[msg_id] = now
if len(self._seen) > self._max_size:
cutoff = now - self._ttl

View File

@@ -9725,9 +9725,9 @@ def main():
config = None
if args.config:
import json
import yaml
with open(args.config, encoding="utf-8") as f:
data = json.load(f)
data = yaml.safe_load(f)
config = GatewayConfig.from_dict(data)
# Run the gateway - exit with code 1 if no platforms connected,