From 79d0a221b218be600ddc40bafa71c8ad1fef94d9 Mon Sep 17 00:00:00 2001 From: eV <8796196+evq@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:59:50 +0000 Subject: [PATCH] fix error return and make QLDB hash verification a warning (#2060) --- services/payments/datastore.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/payments/datastore.go b/services/payments/datastore.go index ffa91bdcc..1d74a9a7f 100644 --- a/services/payments/datastore.go +++ b/services/payments/datastore.go @@ -107,6 +107,8 @@ func (q *QLDBDatastore) InsertPaymentState(ctx context.Context, state *paymentLi } func (q *QLDBDatastore) GetPaymentStateHistory(ctx context.Context, documentID string) (*paymentLib.PaymentStateHistory, error) { + logger := logging.Logger(ctx, "payments.setupLedger") + stateHistory, err := q.Execute(context.Background(), func(txn qldbdriver.Transaction) (interface{}, error) { result, err := txn.Execute( "SELECT * FROM history(transactions) AS h WHERE h.metadata.id = ?", @@ -131,16 +133,21 @@ func (q *QLDBDatastore) GetPaymentStateHistory(ctx context.Context, documentID s merkleValid, err := revisionValidInTree(ctx, q.sdkClient, &latestHistoryItem) if err != nil { - return nil, fmt.Errorf("failed to verify Merkle tree: %w", err) + //return nil, fmt.Errorf("failed to verify Merkle tree: %w", err) + logger.Warn().Err(err).Msg("failed to verify Merkle tree") } if !merkleValid { - return nil, fmt.Errorf("invalid Merkle tree for record: %#v", latestHistoryItem) + //return nil, fmt.Errorf("invalid Merkle tree for record: %#v", latestHistoryItem) + logger.Warn().Msg("invalid Merkle tree for record") } tmp := paymentLib.PaymentStateHistory(stateHistory) return &tmp, nil }) + if err != nil { + return nil, err + } return stateHistory.(*paymentLib.PaymentStateHistory), err }