From 7fcf141df16d1b0926475ffa9e3a54d56038d7c5 Mon Sep 17 00:00:00 2001 From: artaasadi Date: Sun, 8 Dec 2024 23:54:57 +0100 Subject: [PATCH] fix: fix nil pointer exception --- provider/describer/workflow.go | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/provider/describer/workflow.go b/provider/describer/workflow.go index 2e60969a..b2f2c8fb 100644 --- a/provider/describer/workflow.go +++ b/provider/describer/workflow.go @@ -51,23 +51,32 @@ func GetRepositoryWorkflows(ctx context.Context, githubClient GitHubClient, stre return nil, err } for _, workflow := range workflows.Workflows { - fileContent, err := getWorkflowFileContent(ctx, client, workflow, owner, repo) - if err != nil { - return nil, err + if workflow == nil { + continue } - content, err := fileContent.GetContent() + var pipeline *goPipeline.Pipeline + var content string + + fileContent, err := getWorkflowFileContent(ctx, client, workflow, owner, repo) if err != nil { return nil, err } - fileContentBasic := FileContent{ - Repository: repo, - FilePath: fileContent.GetPath(), - Content: content, - } - pipeline, err := decodeFileContentToPipeline(fileContentBasic) - if err != nil { - return nil, err + if fileContent != nil { + content, err = fileContent.GetContent() + if err != nil { + return nil, err + } + fileContentBasic := FileContent{ + Repository: repo, + FilePath: fileContent.GetPath(), + Content: content, + } + pipeline, err = decodeFileContentToPipeline(fileContentBasic) + if err != nil { + return nil, err + } } + value := models.Resource{ ID: strconv.Itoa(int(workflow.GetID())), Name: workflow.GetName(),