From c090fa9775d1db215ae70b2a24cf205d3e124c17 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 10 Jan 2026 20:06:11 -0800 Subject: [PATCH] Fix fuzzy matching lists of object / names --- src/paperless_ai/matching.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/paperless_ai/matching.py b/src/paperless_ai/matching.py index 30adbbd7c..f1dfc62db 100644 --- a/src/paperless_ai/matching.py +++ b/src/paperless_ai/matching.py @@ -71,9 +71,9 @@ def _match_names_to_queryset(names: list[str], queryset, attr: str): # First try exact match if target in object_names: index = object_names.index(target) - results.append(objects[index]) - # Remove the matched name from the list to avoid fuzzy matching later - object_names.remove(target) + matched = objects.pop(index) + object_names.pop(index) # keep object list aligned after removal + results.append(matched) continue # Fuzzy match fallback @@ -85,7 +85,9 @@ def _match_names_to_queryset(names: list[str], queryset, attr: str): ) if matches: index = object_names.index(matches[0]) - results.append(objects[index]) + matched = objects.pop(index) + object_names.pop(index) + results.append(matched) else: pass return results