From 85e28c9f31a3c273c9fcec64cd3894236d3d3cb9 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Thu, 12 Mar 2026 12:17:24 -0700 Subject: [PATCH] Remove duplicate key violation from idempotent error patterns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "duplicate key value violates" on CREATE UNIQUE INDEX means the index can't be created due to duplicate data — this is NOT idempotent. Marking it as applied silently skips index creation, leaving the DB without the unique constraint. Co-Authored-By: Claude Opus 4.6 --- litellm-proxy-extras/litellm_proxy_extras/utils.py | 1 - .../litellm-proxy-extras/test_litellm_proxy_extras_utils.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/litellm-proxy-extras/litellm_proxy_extras/utils.py b/litellm-proxy-extras/litellm_proxy_extras/utils.py index 2930c128c8d..30aba6b1f49 100644 --- a/litellm-proxy-extras/litellm_proxy_extras/utils.py +++ b/litellm-proxy-extras/litellm_proxy_extras/utils.py @@ -230,7 +230,6 @@ class ProxyExtrasDBManager: idempotent_patterns = [ r"already exists", r"column .* already exists", - r"duplicate key value violates", r"relation .* already exists", r"constraint .* already exists", r"does not exist", diff --git a/tests/litellm-proxy-extras/test_litellm_proxy_extras_utils.py b/tests/litellm-proxy-extras/test_litellm_proxy_extras_utils.py index a8eff29b17b..38890ff8c5e 100644 --- a/tests/litellm-proxy-extras/test_litellm_proxy_extras_utils.py +++ b/tests/litellm-proxy-extras/test_litellm_proxy_extras_utils.py @@ -86,10 +86,10 @@ class TestIdempotentErrorDetection: error_message = "column 'email' already exists" assert ProxyExtrasDBManager._is_idempotent_error(error_message) is True - def test_is_idempotent_error_duplicate_key(self): - """Test detection of duplicate key violation error""" + def test_duplicate_key_violation_not_idempotent(self): + """Duplicate key violations (e.g., CREATE INDEX with duplicate data) are NOT idempotent""" error_message = "duplicate key value violates unique constraint" - assert ProxyExtrasDBManager._is_idempotent_error(error_message) is True + assert ProxyExtrasDBManager._is_idempotent_error(error_message) is False def test_is_idempotent_error_relation_already_exists(self): """Test detection of 'relation already exists' error"""