From 5ac79717a12f23c48012f5e70ee239326ca69a0c Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Wed, 16 Oct 2024 11:55:47 +0530 Subject: [PATCH] fix: handle nil pointer error --- connection/aws.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connection/aws.go b/connection/aws.go index dc178f62..4f678e56 100644 --- a/connection/aws.go +++ b/connection/aws.go @@ -68,7 +68,10 @@ func (t *AWSConnection) Populate(ctx ConnectionContext) error { if t.ConnectionName != "" { connection, err := ctx.HydrateConnectionByURL(t.ConnectionName) if err != nil { - return fmt.Errorf("could not parse EC2 access key: %v", err) + return fmt.Errorf("could not parse EC2 access key: %w", err) + } + if connection == nil { + return fmt.Errorf("connection[%s] not found", t.ConnectionName) } t.AccessKey.ValueStatic = connection.Username