From 43a2979e77439085c603df7edd4117a6cf52db51 Mon Sep 17 00:00:00 2001 From: Pete Davison Date: Sun, 17 Dec 2023 02:44:03 +0000 Subject: [PATCH] fix: non-evaluated nil values should be converted to empty strings to avoid empty interface errors in the templater --- internal/compiler/v3/compiler_v3.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/compiler/v3/compiler_v3.go b/internal/compiler/v3/compiler_v3.go index c66ec2b2..2b62347d 100644 --- a/internal/compiler/v3/compiler_v3.go +++ b/internal/compiler/v3/compiler_v3.go @@ -71,6 +71,12 @@ func (c *CompilerV3) getVariables(t *taskfile.Task, call *taskfile.Call, evaluat if err := tr.Err(); err != nil { return err } + // If the variable should not be evaluated, but is nil, set it to an empty string + // This stops empty interface errors when using the templater to replace values later + if !evaluateShVars && newVar.Value == nil { + result.Set(k, taskfile.Var{Value: ""}) + return nil + } // If the variable is not dynamic, we can set it and return if !evaluateShVars || newVar.Value != nil || newVar.Sh == "" { result.Set(k, taskfile.Var{Value: newVar.Value})