hashicorp/packer · error
Error parsing target template: %s
Error message
Error parsing target template: %s
What it means
Configuration-time validation for the checksum post-processor: the `output` path is a template processed by Packer's HCL2-style interpolation engine, and interpolate.Validate rejects it when the template is syntactically invalid (unbalanced braces, unknown/misspelled variables used in ways validation rejects, malformed functions).
Source
Thrown at post-processor/checksum/post-processor.go:91
if p.config.ChecksumTypes == nil {
p.config.ChecksumTypes = []string{"md5"}
}
for _, k := range p.config.ChecksumTypes {
if h := getHash(k); h == nil {
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Unrecognized checksum type: %s", k))
}
}
if p.config.OutputPath == "" {
p.config.OutputPath = "packer_{{.BuildName}}_{{.BuilderType}}_{{.ChecksumType}}.checksum"
}
if err = interpolate.Validate(p.config.OutputPath, &p.config.ctx); err != nil {
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error parsing target template: %s", err))
}
if len(errs.Errors) > 0 {
return errs
}
return nil
}
func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) {
files := artifact.Files()
var h hash.Hash
var generatedData map[interface{}]interface{}
stateData := artifact.State("generated_data")
if stateData != nil {
// Make sure it's not a nil map so we can assign to it later.
generatedData = stateData.(map[interface{}]interface{})View on GitHub (pinned to eb36e3c3e4)
Solutions
- Fix the template syntax — every placeholder must be {{.Variable}} with balanced braces
- Only use the supported variables: .BuildName, .BuilderType, .ChecksumType
- Test the path with packer validate before running the build
Example fix
// before
output = "packer/{{.BuildName}.checksum"
// after (closed placeholder / valid vars)
output = "packer/{{.BuildName}}_{{.ChecksumType}}.checksum" Defensive patterns
Strategy: validation
Validate before calling
// Go: pre-validate the output template the same way Packer does
ctx := &interpolate.Context{BuildName: "b", BuilderType: "t"}
if err := interpolate.Validate("packer_{{.BuildName}}_{{.ChecksumType}}.checksum", ctx); err != nil {
log.Fatalf("invalid checksum output template: %v", err)
} Try / catch
if err := pp.Configure(raws); err != nil {
if strings.Contains(err.Error(), "Error parsing target template") {
// fix output placeholder syntax: {{.Var}} with balanced braces
}
return err
} Prevention
- Use balanced {{.Variable}} placeholders only
- Stick to the supported variables: .BuildName, .BuilderType, .ChecksumType
- Don't paste shell ${VAR} syntax into Packer output templates
- Run packer validate on every template change
When it happens
Trigger: Setting an `output` value like "dir/{{.BuildName" (unclosed placeholder), "{{.Foo}}" (unknown variable), or invoking a nonexistent function — interpolate.Validate against the config context fails and the error is appended to errs.
Common situations: Hand-edited output paths with typos; copying shell `${VAR}` syntax instead of Packer's {{.Var}}; using variables not in the checksum context (BuildName, BuilderType, ChecksumType).
Related errors
- Unrecognized checksum type: %s
- unable to create dir: %s
- unable to create file %s: %s
- unable to open file %s: %s
- The post-processor %s is unknown by Packer, and is likely pa
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/055e0ba1b8021dd4.
Report an issue: GitHub.