Skip to content

Commit 0274227

Browse files
sameh-faroukclaude
andauthored
fix(bridge): correct error wrapping, trace_id key, and a log message (#1095)
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 <nil>. 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) <noreply@anthropic.com>
1 parent c395377 commit 0274227

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

bridge/tfchain_bridge/pkg/bridge/bridge.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (bridge *Bridge) Start(ctx context.Context) error {
146146
select {
147147
case data := <-tfchainSub:
148148
if data.Err != nil {
149-
return errors.Wrap(err, "failed to get tfchain events")
149+
return errors.Wrap(data.Err, "failed to get tfchain events")
150150
}
151151
for _, withdrawCreatedEvent := range data.Events.WithdrawCreatedEvents {
152152
err := bridge.handleWithdrawCreated(ctx, withdrawCreatedEvent)
@@ -190,7 +190,7 @@ func (bridge *Bridge) Start(ctx context.Context) error {
190190
}
191191
case data := <-stellarSub:
192192
if data.Err != nil {
193-
return errors.Wrap(err, "failed to get stellar payments")
193+
return errors.Wrap(data.Err, "failed to get stellar payments")
194194
}
195195

196196
for _, mEvent := range data.Events {

bridge/tfchain_bridge/pkg/stellar/stellar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func (w *StellarWallet) submitTransaction(ctx context.Context, txn *txnbuild.Tra
368368
return errors.Wrap(err, "an error occurred while submitting the transaction")
369369
}
370370
log.Info().
371-
Str("trace_id", fmt.Sprint(ctx.Value("trace_id"))).
371+
Str("trace_id", fmt.Sprint(ctx.Value(TraceIdKey{}))).
372372
Str("event_action", "stellar_transaction_submitted").
373373
Str("event_kind", "event").
374374
Str("category", "vault").

bridge/tfchain_bridge/pkg/substrate/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func NewSubstrateClient(url string, seed string) (*SubstrateClient, error) {
6363
func (s *SubstrateClient) RetrySetWithdrawExecuted(ctx context.Context, tixd uint64) error {
6464
err := s.SetBurnTransactionExecuted(s.identity, tixd)
6565
for err != nil {
66-
log.Err(err).Msg("error while setting refund transaction as executed")
66+
log.Err(err).Msg("error while setting burn transaction as executed")
6767

6868
select {
6969
case <-ctx.Done():

0 commit comments

Comments
 (0)