From 03158da93856d8691d277dd1f3bbce8014104b36 Mon Sep 17 00:00:00 2001 From: Regg819 Date: Wed, 1 Apr 2026 01:02:13 +0000 Subject: [PATCH] fix: handle empty prefix in list_corrupted_runs to prevent IndexError When decode_path() returns an empty list for an empty byte string prefix, accessing [-1] causes IndexError. This fix adds a check to return None for empty paths and filters them out, preventing the crash. Fixes issue #3390 --- aim/sdk/repo.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aim/sdk/repo.py b/aim/sdk/repo.py index 1ffef1c9b..0bc6bd7e8 100644 --- a/aim/sdk/repo.py +++ b/aim/sdk/repo.py @@ -397,10 +397,13 @@ def list_corrupted_runs(self) -> List[str]: from aim.storage.encoding import decode_path def get_run_hash_from_prefix(prefix: bytes): - return decode_path(prefix)[-1] + path = decode_path(prefix) + if not path: + return None + return path[-1] container = RocksUnionContainer(os.path.join(self.path, 'meta'), read_only=True) - return list(map(get_run_hash_from_prefix, container.corrupted_dbs)) + return [h for h in map(get_run_hash_from_prefix, container.corrupted_dbs) if h is not None] def _active_run_hashes(self) -> Set[str]: if self.is_remote_repo: