mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	Do not crash when parsing an invalid workflow file (#23972)
Fix #23658. Related to https://gitea.com/gitea/act/pulls/39
This commit is contained in:
		@@ -17,8 +17,18 @@ import (
 | 
			
		||||
	"github.com/nektos/act/pkg/jobparser"
 | 
			
		||||
	"github.com/nektos/act/pkg/model"
 | 
			
		||||
	"github.com/nektos/act/pkg/workflowpattern"
 | 
			
		||||
	"gopkg.in/yaml.v3"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	model.OnDecodeNodeError = func(node yaml.Node, out interface{}, err error) {
 | 
			
		||||
		// Log the error instead of panic or fatal.
 | 
			
		||||
		// It will be a big job to refactor act/pkg/model to return decode error,
 | 
			
		||||
		// so we just log the error and return empty value, and improve it later.
 | 
			
		||||
		log.Error("Failed to decode node %v into %T: %v", node, out, err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ListWorkflows(commit *git.Commit) (git.Entries, error) {
 | 
			
		||||
	tree, err := commit.SubTree(".gitea/workflows")
 | 
			
		||||
	if _, ok := err.(git.ErrNotExist); ok {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user