hashicorp/nomad · error
error parsing env template %q: %v
Error message
error parsing env template %q: %v
What it means
In loadTemplateEnv, envparse.Parse fails on the contents of a rendered env template file — the file exists but is not valid KEY=value environment syntax (bad quoting, invalid lines). The template rendered successfully but its content cannot become task environment variables.
Source
Thrown at client/allocrunner/taskrunner/template/template.go:1093
func loadTemplateEnv(tmpls []*structs.Template, taskEnv *taskenv.TaskEnv) (map[string]string, error) {
all := make(map[string]string, 50)
for _, t := range tmpls {
if !t.Envvars {
continue
}
// we checked escape before we rendered the file
dest, _ := taskEnv.ClientPath(t.DestPath, true)
f, err := os.Open(dest)
if err != nil {
return nil, fmt.Errorf("error opening env template: %v", err)
}
defer f.Close()
// Parse environment fil
vars, err := envparse.Parse(f)
if err != nil {
return nil, fmt.Errorf("error parsing env template %q: %v", dest, err)
}
maps.Copy(all, vars)
}
return all, nil
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Fix the template so its rendered output is valid key=value env syntax
- Check for stray quotes, empty keys, or invalid characters in the rendered file
- Test the template rendering locally before submitting the job
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at client/allocrunner/taskrunner/template/template.go:1093 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/605000268b8dbc38.
Report an issue: GitHub.