Defensive: try/except around decode in _row_to_message

Decode errors now log to stderr instead of crashing the entire
API response. This prevents a single malformed message from hiding
all subsequent messages in the same query.
This commit is contained in:
catarrh committed 2026-08-12 17:49:05 +03:00
1 parent e211dd91bc
commit 41b5c0218e
1 file changed
+5
+5
View File
@@ -177,6 +177,11 @@ class Database:
'flags': row[5],
}
if row[3] in ('tpdu', 'change', 'fidi', 'atr', 'pps') and data_blob:
try:
from .decode import decode_sniff_msg
msg['decoded'] = decode_sniff_msg(data_blob, row[3])
except Exception as e:
import sys
print(f'Decode error for msg {row[0]} ({row[3]}, {len(data_blob)} bytes): {e}',
file=sys.stderr)
return msg