From 79b742bd09b726007389c4f27f5bdb6fe79adf24 Mon Sep 17 00:00:00 2001 From: Sameh Abouel-saad Date: Mon, 1 Jun 2026 21:18:51 +0300 Subject: [PATCH] fix(bridge): correct error wrapping, trace_id key, and a log message Three diagnostics/observability fixes (no behavior change to fund flow): 1. bridge.go: the tfchain and stellar subscription error branches checked `data.Err != nil` but wrapped the stale outer-scope `err`, so a real subscription failure was reported with the wrong/empty cause. Wrap `data.Err` in both arms. 2. stellar.go: the `stellar_transaction_submitted` success log read the trace id with the string key `ctx.Value("trace_id")`, but the value is stored under the typed key `TraceIdKey{}`, so trace_id was always logged as . Use `TraceIdKey{}`. 3. client.go: RetrySetWithdrawExecuted (which calls SetBurnTransactionExecuted) logged "setting refund transaction as executed". Corrected to "burn transaction". Co-Authored-By: Claude Opus 4.8 (1M context) --- bridge/tfchain_bridge/pkg/bridge/bridge.go | 4 ++-- bridge/tfchain_bridge/pkg/stellar/stellar.go | 2 +- bridge/tfchain_bridge/pkg/substrate/client.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bridge/tfchain_bridge/pkg/bridge/bridge.go b/bridge/tfchain_bridge/pkg/bridge/bridge.go index 92c9d48d7..7428f3713 100644 --- a/bridge/tfchain_bridge/pkg/bridge/bridge.go +++ b/bridge/tfchain_bridge/pkg/bridge/bridge.go @@ -146,7 +146,7 @@ func (bridge *Bridge) Start(ctx context.Context) error { select { case data := <-tfchainSub: if data.Err != nil { - return errors.Wrap(err, "failed to get tfchain events") + return errors.Wrap(data.Err, "failed to get tfchain events") } for _, withdrawCreatedEvent := range data.Events.WithdrawCreatedEvents { err := bridge.handleWithdrawCreated(ctx, withdrawCreatedEvent) @@ -190,7 +190,7 @@ func (bridge *Bridge) Start(ctx context.Context) error { } case data := <-stellarSub: if data.Err != nil { - return errors.Wrap(err, "failed to get stellar payments") + return errors.Wrap(data.Err, "failed to get stellar payments") } for _, mEvent := range data.Events { diff --git a/bridge/tfchain_bridge/pkg/stellar/stellar.go b/bridge/tfchain_bridge/pkg/stellar/stellar.go index 7f923744e..fd4e19b33 100644 --- a/bridge/tfchain_bridge/pkg/stellar/stellar.go +++ b/bridge/tfchain_bridge/pkg/stellar/stellar.go @@ -368,7 +368,7 @@ func (w *StellarWallet) submitTransaction(ctx context.Context, txn *txnbuild.Tra return errors.Wrap(err, "an error occurred while submitting the transaction") } log.Info(). - Str("trace_id", fmt.Sprint(ctx.Value("trace_id"))). + Str("trace_id", fmt.Sprint(ctx.Value(TraceIdKey{}))). Str("event_action", "stellar_transaction_submitted"). Str("event_kind", "event"). Str("category", "vault"). diff --git a/bridge/tfchain_bridge/pkg/substrate/client.go b/bridge/tfchain_bridge/pkg/substrate/client.go index d3461b458..eb61c9f4d 100644 --- a/bridge/tfchain_bridge/pkg/substrate/client.go +++ b/bridge/tfchain_bridge/pkg/substrate/client.go @@ -63,7 +63,7 @@ func NewSubstrateClient(url string, seed string) (*SubstrateClient, error) { func (s *SubstrateClient) RetrySetWithdrawExecuted(ctx context.Context, tixd uint64) error { err := s.SetBurnTransactionExecuted(s.identity, tixd) for err != nil { - log.Err(err).Msg("error while setting refund transaction as executed") + log.Err(err).Msg("error while setting burn transaction as executed") select { case <-ctx.Done():