{"record":{"id":"605000268b8dbc38","repo":"hashicorp/nomad","slug":"error-parsing-env-template-q-v","errorCode":null,"errorMessage":"error parsing env template %q: %v","messagePattern":"error parsing env template %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/taskrunner/template/template.go","lineNumber":1093,"sourceCode":"func loadTemplateEnv(tmpls []*structs.Template, taskEnv *taskenv.TaskEnv) (map[string]string, error) {\n\tall := make(map[string]string, 50)\n\tfor _, t := range tmpls {\n\t\tif !t.Envvars {\n\t\t\tcontinue\n\t\t}\n\n\t\t// we checked escape before we rendered the file\n\t\tdest, _ := taskEnv.ClientPath(t.DestPath, true)\n\t\tf, err := os.Open(dest)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error opening env template: %v\", err)\n\t\t}\n\t\tdefer f.Close()\n\n\t\t// Parse environment fil\n\t\tvars, err := envparse.Parse(f)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error parsing env template %q: %v\", dest, err)\n\t\t}\n\t\tmaps.Copy(all, vars)\n\t}\n\treturn all, nil\n}\n","sourceCodeStart":1075,"sourceCodeEnd":1099,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/taskrunner/template/template.go#L1075-L1099","documentation":"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.","triggerScenarios":"Thrown at client/allocrunner/taskrunner/template/template.go:1093 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}