diff --git a/sdk/messaging/azservicebus/internal/errors.go b/sdk/messaging/azservicebus/internal/errors.go index d833bf0609f4..34ef7bea5bbb 100644 --- a/sdk/messaging/azservicebus/internal/errors.go +++ b/sdk/messaging/azservicebus/internal/errors.go @@ -158,6 +158,13 @@ func isRetryableAMQPError(ctxForLogging context.Context, err error) bool { return ok } + var amqpDetachErr *amqp.DetachError + var isAMQPDetachError = errors.As(err, &amqpDetachErr) + + if isAMQPDetachError { + return isRetryableAMQPError(ctxForLogging, amqpDetachErr.RemoteError) + } + // TODO: there is a bug somewhere that seems to be errorString'ing errors. Need to track that down. // In the meantime, try string matching instead for condition := range retryableAMQPConditions { diff --git a/sdk/messaging/azservicebus/internal/errors_test.go b/sdk/messaging/azservicebus/internal/errors_test.go index 471e7d96ad6d..5d340c21ac0f 100644 --- a/sdk/messaging/azservicebus/internal/errors_test.go +++ b/sdk/messaging/azservicebus/internal/errors_test.go @@ -113,6 +113,11 @@ func Test_isRetryableAMQPError(t *testing.T) { require.True(t, isRetryableAMQPError(ctx, &amqp.Error{ Condition: amqp.ErrorCondition(code), })) + require.True(t, isRetryableAMQPError(ctx, &amqp.DetachError{ + RemoteError: &amqp.Error{ + Condition: amqp.ErrorCondition(code), + }, + })) // it works equally well if the error is just in the String(). // Need to narrow this down some more to see where the errors