Skip to content

Commit

Permalink
fix: string cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
iamKunalGupta committed Mar 6, 2024
1 parent bc2f5da commit e85310b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions flow/shared/telemetry/sns_message_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ func (s *SNSMessageSenderImpl) SendMessage(ctx context.Context, subject string,
h.Write([]byte(deduplicationString))
deduplicationHash := hex.EncodeToString(h.Sum(nil))
// AWS SNS Subject constraints
messageSubject := strings.TrimFunc(subject, func(r rune) bool {
return !unicode.IsPrint(r)
})
if len(messageSubject) >= 100 {
messageSubject = messageSubject[:99]
messageSubject := ""
for _, char := range subject {
if unicode.IsPrint(char) {
messageSubject += string(char)
}
}
maxSubjectSize := 99
if len(messageSubject) > maxSubjectSize {
messageSubject = messageSubject[:maxSubjectSize]
}
publish, err := s.client.Publish(ctx, &sns.PublishInput{
Message: aws.String(body),
Expand Down

0 comments on commit e85310b

Please sign in to comment.