From b514649c3da64a1be92b8e22b50e296a07d759f6 Mon Sep 17 00:00:00 2001 From: Alex Savchuk Date: Tue, 6 Sep 2022 23:41:43 +0300 Subject: [PATCH] fix: show workflow name when get error on yml parsing (#1133) (#1328) Additionally close workflow file when a job name is invalid --- pkg/model/planner.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/model/planner.go b/pkg/model/planner.go index fafaa74..16c8928 100644 --- a/pkg/model/planner.go +++ b/pkg/model/planner.go @@ -133,7 +133,7 @@ func NewWorkflowPlanner(path string, noWorkflowRecurse bool) (WorkflowPlanner, e if err == io.EOF { return nil, fmt.Errorf("unable to read workflow '%s': file is empty: %w", wf.workflowFileInfo.Name(), err) } - return nil, err + return nil, fmt.Errorf("workflow is not valid. '%s': %w", wf.workflowFileInfo.Name(), err) } _, err = f.Seek(0, 0) if err != nil { @@ -149,6 +149,7 @@ func NewWorkflowPlanner(path string, noWorkflowRecurse bool) (WorkflowPlanner, e jobNameRegex := regexp.MustCompile(`^([[:alpha:]_][[:alnum:]_\-]*)$`) for k := range workflow.Jobs { if ok := jobNameRegex.MatchString(k); !ok { + _ = f.Close() return nil, fmt.Errorf("workflow is not valid. '%s': Job name '%s' is invalid. Names must start with a letter or '_' and contain only alphanumeric characters, '-', or '_'", workflow.Name, k) } }