hashicorp/packer · error

Error parsing target template: %s

Error message

Error parsing target template: %s

What it means

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.

Source

Thrown at post-processor/manifest/post-processor.go:72

func (p *PostProcessor) Configure(raws ...interface{}) error {
	err := config.Decode(&p.config, &config.DecodeOpts{
		PluginType:         "packer.post-processor.manifest",
		Interpolate:        true,
		InterpolateContext: &p.config.ctx,
		InterpolateFilter: &interpolate.RenderFilter{
			Exclude: []string{},
		},
	}, raws...)
	if err != nil {
		return err
	}

	if p.config.OutputPath == "" {
		p.config.OutputPath = "packer-manifest.json"
	}

	if err = interpolate.Validate(p.config.OutputPath, &p.config.ctx); err != nil {
		return fmt.Errorf("Error parsing target template: %s", err)
	}

	return nil
}

func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, source packersdk.Artifact) (packersdk.Artifact, bool, bool, error) {
	generatedData := source.State("generated_data")
	if generatedData == nil {
		// Make sure it's not a nil map so we can assign to it later.
		generatedData = make(map[string]interface{})
	}
	p.config.ctx.Data = generatedData

	for key, data := range p.config.CustomData {
		interpolatedData, err := createInterpolatedCustomData(&p.config, data)
		if err != nil {
			return nil, false, false, err
		}

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Fix the interpolation syntax in output_path — every `{{` must be closed and reference a known variable (e.g. `{{build_name}}`).
  2. Run `packer validate template.pkr.hcl` to reproduce the exact parse error before building.
  3. If no templating is needed, set output_path to a plain literal path like `packer-manifest.json`.
  4. Check for stray characters or quotes inside the path string.

Example fix

// before
output_path = "manifest/{{build_name}.json"
// after
output_path = "manifest/{{build_name}}.json"
Defensive patterns

Strategy: validation

Validate before calling

# catch malformed interpolation before building
packer validate template.pkr.hcl

Prevention

When it happens

Trigger: output_path contains malformed interpolation — e.g. unbalanced `{{`, unknown/invalid function calls, or bad variable syntax that interpolate.Validate rejects.

Common situations: 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.

Related errors


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/a47b2c8b1876237e. Report an issue: GitHub.