-
-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce validation for taskfile field in includes #1902
base: main
Are you sure you want to change the base?
Conversation
The distinction here is whether or not Opinion: I think we should error in the
I can't see a situation where an empty string is useful. |
@pd93 We can use |
I totally agree with you @pd93 ! |
Hey @semihbkgr, |
Hi @vmaerten, |
@@ -113,6 +113,11 @@ func (includes *Includes) UnmarshalYAML(node *yaml.Node) error { | |||
keyNode := node.Content[i] | |||
valueNode := node.Content[i+1] | |||
|
|||
// Ensure the include value is not null, as it must be either a string or an include object. | |||
if valueNode.Kind == yaml.ScalarNode && valueNode.Tag == "!!null" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null
check is placed before decoding the valueNode
because the Decode
method from the yaml package does not invoke the UnmarshalYAML
method if the node is null
. This ensures that null
values are caught early and handled with a proper error message, as the UnmarshalYAML
logic would be skipped for such nodes.
fixes #1881
This makes the
taskfile
field withininclude
required, disallowingnull
(unspecified) or empty values, even if inlined.I’d like to clarify two points, @pd93:
1- Would it be preferable to return a
TaskfileDecodeError
in theUnmarshalYAML
function when parsing the yaml intoInclude
? This approach could make the error message more descriptive.However, I aligned this error with the existing one we return when the
Taskfile
is not existing ("no such file or directory"), which is why the error is returned after the parsing step.2- Should we differentiate between null and empty string values, or should we treat them the same and return an error for both?