Skip to content

YamlParsing Error while calling FindYamlByPath function in harness-go-sdk #277

@snp1606

Description

@snp1606

Hi Team,
I am trying to update my harness-go-sdk version from 0.1.11 to 0.3.9 and in one of our terraform module its failing on the terratest.
Below are the details . Please check the details and suggest the fix/resolution for doing the backward compatibility while upgrading the harness-go-sdk version.
I have checked the arguments passed to FindYamlByPath which are 'id' and 'path' and they are getting valid values. Please let me know if you need any further information from the code to reproduce the error.

# The line which gives error
workflowYamlItem err := client.ConfigAsCodeClient.FindYamlByPath(fmt.Sprint(applicationAttributes["id"]), cac.YamlPath(path)

# Error message :
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: nvalid memory address or nil pointer dereference

# Client Configuration for Harness

client, err := cd.NewClient(&cd.Config{
AccoundId: helpers.EnvVars.AccountId.Get(),
APIKey: helpers.EnvVars.ApiKey.Get(),
Endpoint: "https://app.harness.io/gateway",
DefaultHeader: make(map[string]string),
HTTPClient: &retryablehttp.Client{
RetryMax: 10,
RetryWaitMin: 5 * time.Second,
RetryWaitMax: 10 * time.Second,
HTTPClient: &http.client{
Timeout: 10 * time.Second,
},
Backoff: retryablehttp.DefaultBackoff,
CheckRetry: retryablehttp.DefaultRetryPolicy,
}
DebugLogging: true,
})

# imports in go.mod ( go version 1.16 )

github.com/gruntwork-io/terratest v0.40.2
github.com/harness/harness-go-sdk v0.3.9
github.com/hashicorp/go-retryablehttp v0.7.1
github.com/stretchr/testify v.1.7.1
gopkg.in/yaml.v3 v3.0.1

# Terratest imports :
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/harness/harness-go-sdk/harness/cd"
"github.com/harness/harness-go-sdk/harness/helpers"
"github.com/hashicorp/go-retryablehttp"
"github.com/harness/harness-go-sdk/harness/cd/cac"
"github.com/stretchr/testify/require"
"testing"
"os"
"encoding/json"
"fmt"
"gopkg.in/yaml.v3"
"time"
"net/http"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions