Skip to content

Commit 8beb552

Browse files
committed
fixed NPE for fetching an optional field in GetQueueUrlInput
Signed-off-by: Vivien Ng <[email protected]>
1 parent 256494f commit 8beb552

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/services/awssqs.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,17 @@ type SQSSendMessageAPI interface {
192192
}
193193

194194
var GetQueueURL = func(c context.Context, api SQSSendMessageAPI, input *sqs.GetQueueUrlInput) (*sqs.GetQueueUrlOutput, error) {
195-
log.Infof("[GetQueueUrl] queue_name: %s, account_id: %s", *input.QueueName, *input.QueueOwnerAWSAccountId)
195+
// QueueName is required, QueueOwnerAWSAccountId is optional
196+
accountIdStr := ""
197+
if input.QueueOwnerAWSAccountId != nil {
198+
accountIdStr = ", account_id: " + *input.QueueOwnerAWSAccountId
199+
}
200+
log.Infof("[GetQueueUrl] queue_name: %s%s", *input.QueueName, accountIdStr)
196201
return api.GetQueueUrl(c, input)
197202
}
198203

199204
var SendMsg = func(c context.Context, api SQSSendMessageAPI, input *sqs.SendMessageInput) (*sqs.SendMessageOutput, error) {
205+
// QueueUrl & MessageBody are required fields.
200206
log.Infof("[SendMsg] queue_url: %s, message_body: %s", *input.QueueUrl, *input.MessageBody)
201207
return api.SendMessage(c, input)
202208
}

0 commit comments

Comments
 (0)