fix: reject include without taskfile or dir (#2892)

Co-authored-by: Valentin Maerten <maerten.valentin@gmail.com>
This commit is contained in:
qingyingliu
2026-07-01 12:48:47 -07:00
committed by GitHub
parent b5f671e098
commit b5861b1e27
4 changed files with 41 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package ast
import (
"iter"
"strings"
"sync"
"github.com/elliotchance/orderedmap/v3"
@@ -171,6 +172,9 @@ func (include *Include) UnmarshalYAML(node *yaml.Node) error {
if err := node.Decode(&includedTaskfile); err != nil {
return errors.NewTaskfileDecodeError(err, node)
}
if strings.TrimSpace(includedTaskfile.Taskfile) == "" && strings.TrimSpace(includedTaskfile.Dir) == "" {
return errors.NewTaskfileDecodeError(nil, node).WithMessage("include must specify taskfile or dir")
}
include.Taskfile = includedTaskfile.Taskfile
include.Dir = includedTaskfile.Dir
include.Optional = includedTaskfile.Optional