Remove duplicate key violation from idempotent error patterns

"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 <noreply@anthropic.com>
This commit is contained in:
yuneng-jiang 2026-03-12 12:17:24 -07:00
parent fdd8a706ba
commit 85e28c9f31
2 changed files with 3 additions and 4 deletions

View file

@ -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",

View file

@ -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"""