From c9408ebbc80c76111464abf224a3a51df8a3334b Mon Sep 17 00:00:00 2001 From: Charles Dixon Date: Wed, 4 Oct 2023 13:55:34 +0100 Subject: [PATCH] GOCBC-1493: Update how we assign errors in setting kv durability Motivation ----------- When we set durability level options on an op after setting the value then we will swallow any transcoding errors as we assign the error value straight into the op manager error, even if that value is nil. Changes ------- Update op manager so that the error is only assigned if it is non-nil after translating to memd. Change-Id: Ieb01b295b6ea1bd82e6459d2b15d1e781270911d Reviewed-on: https://review.couchbase.org/c/gocb/+/198636 Reviewed-by: Dimitris Christodoulou Tested-by: Charles Dixon --- kvopmanager.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kvopmanager.go b/kvopmanager.go index cb37327..2887e89 100644 --- a/kvopmanager.go +++ b/kvopmanager.go @@ -121,7 +121,13 @@ func (m *kvOpManager) SetDuraOptions(persistTo, replicateTo uint, level Durabili m.persistTo = persistTo m.replicateTo = replicateTo - m.durabilityLevel, m.err = level.toMemd() + durabilityLevel, err := level.toMemd() + if err != nil { + m.err = err + return + } + + m.durabilityLevel = durabilityLevel if level > DurabilityLevelNone { levelStr, err := level.toManagementAPI()