From f23379a251782bf3df157d0ae297af5b018c738a Mon Sep 17 00:00:00 2001 From: jwinterm Date: Sat, 21 Mar 2026 09:22:53 -0400 Subject: [PATCH] fix: handle None from Redis in get_message_counter The int response callback on hget raises TypeError when the key is missing, so the None check in the mixin never actually executed. Bypass the callback and handle the conversion manually. --- modoboa/policyd/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modoboa/policyd/utils.py b/modoboa/policyd/utils.py index 848862b71..430e9accb 100644 --- a/modoboa/policyd/utils.py +++ b/modoboa/policyd/utils.py @@ -7,5 +7,8 @@ from . import constants def get_message_counter(key): """Return current counter for given key.""" - rclient = get_redis_connection() - return rclient.hget(constants.REDIS_HASHNAME, key) + rclient = get_redis_connection(hget_return_type=None) + value = rclient.hget(constants.REDIS_HASHNAME, key) + if value is None: + return None + return int(value)