{"record":{"id":"a47b2c8b1876237e","repo":"hashicorp/packer","slug":"error-parsing-target-template-s-a47b2c","errorCode":null,"errorMessage":"Error parsing target template: %s","messagePattern":"Error parsing target template: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"post-processor/manifest/post-processor.go","lineNumber":72,"sourceCode":"func (p *PostProcessor) Configure(raws ...interface{}) error {\n\terr := config.Decode(&p.config, &config.DecodeOpts{\n\t\tPluginType:         \"packer.post-processor.manifest\",\n\t\tInterpolate:        true,\n\t\tInterpolateContext: &p.config.ctx,\n\t\tInterpolateFilter: &interpolate.RenderFilter{\n\t\t\tExclude: []string{},\n\t\t},\n\t}, raws...)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif p.config.OutputPath == \"\" {\n\t\tp.config.OutputPath = \"packer-manifest.json\"\n\t}\n\n\tif err = interpolate.Validate(p.config.OutputPath, &p.config.ctx); err != nil {\n\t\treturn fmt.Errorf(\"Error parsing target template: %s\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, source packersdk.Artifact) (packersdk.Artifact, bool, bool, error) {\n\tgeneratedData := source.State(\"generated_data\")\n\tif generatedData == nil {\n\t\t// Make sure it's not a nil map so we can assign to it later.\n\t\tgeneratedData = make(map[string]interface{})\n\t}\n\tp.config.ctx.Data = generatedData\n\n\tfor key, data := range p.config.CustomData {\n\t\tinterpolatedData, err := createInterpolatedCustomData(&p.config, data)\n\t\tif err != nil {\n\t\t\treturn nil, false, false, err\n\t\t}","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/post-processor/manifest/post-processor.go#L54-L90","documentation":"The manifest post-processor validates its output_path configuration with interpolate.Validate, checking that any template variables in the path are well-formed. If the path template is syntactically invalid HCL2/template syntax, Configure fails with this error before any build runs.","triggerScenarios":"output_path contains malformed interpolation — e.g. unbalanced `{{`, unknown/invalid function calls, or bad variable syntax that interpolate.Validate rejects.","commonSituations":"Hand-editing output_path and typo-ing `{{build_name}}` (e.g. `{{build_name}` or `{build_name}}`); pasting shell-style `$VAR` assumptions into the template; copying a path from docs with placeholder braces left intact.","solutions":["Fix the interpolation syntax in output_path — every `{{` must be closed and reference a known variable (e.g. `{{build_name}}`).","Run `packer validate template.pkr.hcl` to reproduce the exact parse error before building.","If no templating is needed, set output_path to a plain literal path like `packer-manifest.json`.","Check for stray characters or quotes inside the path string."],"exampleFix":"// before\noutput_path = \"manifest/{{build_name}.json\"\n// after\noutput_path = \"manifest/{{build_name}}.json\"","handlingStrategy":"validation","validationCode":"# catch malformed interpolation before building\npacker validate template.pkr.hcl","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run `packer validate` before `packer build`.","Balance every `{{ }}` interpolation in output_path.","Use only known variables ({{build_name}}, {{builder_type}}, etc.).","Prefer plain literal paths when templating isn't needed."],"tags":["hcl2","template","configuration","post-processor"],"backgroundTag":"template-parse-error","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}