From 5cf48ac88aeb4dcbea26dfd545d9d6d1a1f93992 Mon Sep 17 00:00:00 2001 From: tezer <4751652+tezer@users.noreply.github.com> Date: Sat, 6 Jan 2024 00:36:13 +0200 Subject: [PATCH] fix(server): handle null key string in utils (check_null_key) Ensure that the `shorten_key` function in `utils.py` returns the key string itself when it is null or empty, preventing further processing that could lead to errors. --- memgpt/server/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/memgpt/server/utils.py b/memgpt/server/utils.py index 14f684f0..fb341e88 100644 --- a/memgpt/server/utils.py +++ b/memgpt/server/utils.py @@ -37,6 +37,8 @@ def shorten_key_middle(key_string, chars_each_side=3): Returns: str: The shortened key string with an ellipsis in the middle. """ + if not key_string: + return key_string key_length = len(key_string) if key_length <= 2 * chars_each_side: return "..." # Return ellipsis if the key is too short