From 912ef480b498f3113e3c297833d898bb37d9bff7 Mon Sep 17 00:00:00 2001 From: Vivien Ng Date: Tue, 26 Nov 2024 23:28:01 -0800 Subject: [PATCH] fixed NPE for fetching an optional field in GetQueueUrlInput --- pkg/services/awssqs.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/services/awssqs.go b/pkg/services/awssqs.go index 4ac3d99..a0eb835 100644 --- a/pkg/services/awssqs.go +++ b/pkg/services/awssqs.go @@ -192,11 +192,17 @@ type SQSSendMessageAPI interface { } var GetQueueURL = func(c context.Context, api SQSSendMessageAPI, input *sqs.GetQueueUrlInput) (*sqs.GetQueueUrlOutput, error) { - log.Infof("[GetQueueUrl] queue_name: %s, account_id: %s", *input.QueueName, *input.QueueOwnerAWSAccountId) + // QueueName is required, QueueOwnerAWSAccountId is optional + accountIdStr := "" + if input.QueueOwnerAWSAccountId != nil { + accountIdStr = ", account_id: " + *input.QueueOwnerAWSAccountId + } + log.Infof("[GetQueueUrl] queue_name: %s%s", *input.QueueName, accountIdStr) return api.GetQueueUrl(c, input) } var SendMsg = func(c context.Context, api SQSSendMessageAPI, input *sqs.SendMessageInput) (*sqs.SendMessageOutput, error) { + // QueueUrl & MessageBody are required fields. log.Infof("[SendMsg] queue_url: %s, message_body: %s", *input.QueueUrl, *input.MessageBody) return api.SendMessage(c, input) }