From 0bed40fef11f9790f5a1d50d8feec36e51f69e92 Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Fri, 11 Aug 2023 12:25:24 +0300
Subject: [PATCH] fix: make ConflictFound cas error message less confusing

---
 src/cas.rs           | 8 ++------
 test/int/test_cas.py | 6 ++----
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/cas.rs b/src/cas.rs
index 3dba57eeb4..62e4c0abda 100644
--- a/src/cas.rs
+++ b/src/cas.rs
@@ -321,11 +321,8 @@ pub enum Error {
     },
 
     /// Checking the predicate revealed a collision.
-    #[error("ConflictFound: comparison failed for index {requested} as it conflicts with {conflict_index}")]
-    ConflictFound {
-        requested: RaftIndex,
-        conflict_index: RaftIndex,
-    },
+    #[error("ConflictFound: found a conflicting entry at index {conflict_index}")]
+    ConflictFound { conflict_index: RaftIndex },
 
     /// Checking the predicate revealed a collision.
     #[error("EntryTermMismatch: entry at index {index} has term {actual_term}, request implies term {expected_term}")]
@@ -404,7 +401,6 @@ impl Predicate {
         storage: &Clusterwide,
     ) -> std::result::Result<(), Error> {
         let error = || Error::ConflictFound {
-            requested: self.index,
             conflict_index: entry_index,
         };
         for range in &self.ranges {
diff --git a/test/int/test_cas.py b/test/int/test_cas.py
index 5e1198dd0a..0b1cc04457 100644
--- a/test/int/test_cas.py
+++ b/test/int/test_cas.py
@@ -129,8 +129,7 @@ def test_cas_predicate(instance: Instance):
     assert e5.value.args == (
         "ER_PROC_C",
         "compare-and-swap: ConflictFound: "
-        + f"comparison failed for index {read_index} "
-        + f"as it conflicts with {read_index+1}",
+        + f"found a conflicting entry at index {read_index+1}",
     )
 
     # Stale index, yet successful insert of another key
@@ -195,7 +194,6 @@ def test_cas_lua_api(cluster: Cluster):
         )
     assert e5.value.args == (
         "compare-and-swap: ConflictFound: "
-        + f"comparison failed for index {read_index} "
-        + f"as it conflicts with {read_index+1}",
+        + f"found a conflicting entry at index {read_index+1}",
     )
     pass
-- 
GitLab