Skip to content

Commit

Permalink
fix: don't crash clearing dead letter info
Browse files Browse the repository at this point in the history
  • Loading branch information
mgabeler-lee-6rs committed May 6, 2024
1 parent cb6feae commit 21aa61f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions services/grpc-subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,16 @@ func (s *subscriberServer) UpdateSubscription(ctx context.Context, req *pubsub.U
}
case "dead_letter_policy":
dlp := req.Subscription.GetDeadLetterPolicy()
if dlp.DeadLetterTopic == "" {
if deadLetterTopicName = dlp.GetDeadLetterTopic(); deadLetterTopicName == "" {
subUpdate.ClearDeadLetterTopicID().ClearMaxDeliveryAttempts()
deadLetterTopicName = ""
} else {
dlt, err := tx.Topic.Query().
Where(topic.Name(dlp.DeadLetterTopic),
Where(topic.Name(deadLetterTopicName),
topic.DeletedAtIsNil()).
Only(ctx)
if err != nil {
if isNotFound(err) {
return status.Errorf(codes.NotFound, "Dead letter topic not found: %s", dlp.DeadLetterTopic)
return status.Errorf(codes.NotFound, "Dead letter topic not found: %s", deadLetterTopicName)
}
return grpc.AsStatusError(err)
}
Expand Down

0 comments on commit 21aa61f

Please sign in to comment.