From fef39dc1e0910eb2dddc4f0ae8baba5b7f8a7886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 13 Mar 2026 01:50:45 +0100 Subject: [PATCH] fix: preserve include directive in output on error in ProcessIncludes All error paths in the ReplaceAllFunc callback returned nil, which ReplaceAllFunc treats as an empty replacement, silently erasing the guard (if err != nil) fired, every subsequent include in the file was also erased. Return spec (the original directive bytes) instead so failed includes are preserved and subsequent ones are not lost. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- includes/templates.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/templates.go b/includes/templates.go index f0ce6a9..e005fab 100644 --- a/includes/templates.go +++ b/includes/templates.go @@ -113,7 +113,7 @@ func ProcessIncludes( contents, func(spec []byte) []byte { if err != nil { - return nil + return spec } groups := reIncludeDirective.FindSubmatch(spec) @@ -143,7 +143,7 @@ func ProcessIncludes( "unable to unmarshal template data config", ) - return nil + return spec } log.Tracef(vardump(facts, data), "including template %q", path) @@ -151,7 +151,7 @@ func ProcessIncludes( templates, err = LoadTemplate(base, includePath, path, left, right, templates) if err != nil { err = facts.Format(err, "unable to load template") - return nil + return spec } var buffer bytes.Buffer @@ -163,7 +163,7 @@ func ProcessIncludes( "unable to execute template", ) - return nil + return spec } recurse = true