hashicorp/packer · error
This version was initially created with a %[2]s template. Ch
Error message
This version was initially created with a %[2]s template. Changing from %[2]s to %[1]s is not supported
What it means
Each HCP Packer bucket version records the template type (HCL2 vs legacy JSON) it was first created with. When a Packer run reuses a fingerprint whose version was created with a different template type than the current run, initializeVersion rejects the run because switching a version's template type mid-way is unsupported and would corrupt registry metadata.
Source
Thrown at internal/hcp/registry/types.bucket.go:491
// load existing version using fingerprint.
version, err := bucket.client.GetVersion(ctx, bucket.Name, bucket.Version.Fingerprint)
if hcpPackerAPI.CheckErrorCode(err, codes.Aborted) {
// probably means Version doesn't exist need a way to check the error
version, err = bucket.createVersion(templateType)
}
if err != nil {
return fmt.Errorf("failed to initialize version for fingerprint %s: %s", bucket.Version.Fingerprint, err)
}
if version == nil {
return fmt.Errorf("failed to initialize version details for Bucket %s with error: %w", bucket.Name, err)
}
if version.TemplateType != nil &&
*version.TemplateType != hcpPackerModels.HashicorpCloudPacker20230101TemplateTypeTEMPLATETYPEUNSET &&
*version.TemplateType != templateType {
return fmt.Errorf(
"This version was initially created with a %[2]s template. "+
"Changing from %[2]s to %[1]s is not supported",
templateType, *version.TemplateType,
)
}
log.Println(
"[TRACE] a valid version was retrieved with the id", version.ID,
)
bucket.Version.ID = version.ID
// If the version is completed and there are no new builds to add, Packer
// should exit and inform the user that artifacts already exists for the
// fingerprint associated with the version.
if bucket.client.IsVersionComplete(version) {
return fmt.Errorf(
"The version associated to the fingerprint %v is complete. If you wish to add a new build to "+
"this bucket a new version must be created by changing the fingerprint.",View on GitHub (pinned to eb36e3c3e4)
Solutions
- Change something that affects the fingerprint (e.g. use a different bucket name or alter build content) so a new version is created
- Delete the existing version in HCP Packer (or the whole bucket) and re-run with the current template type
- Run all runs for this bucket consistently with one template format (pick HCL2 or JSON and stick to it)
Example fix
// before: reusing old fingerprint created from JSON template packer build legacy.json # bucket=my-bucket, fingerprint=abc123 packer build template.pkr.hcl # same fingerprint -> error // after: use a distinct bucket per template type packer build template.pkr.hcl # bucket=my-bucket-hcl
Defensive patterns
Strategy: validation
Validate before calling
// Before running, check the existing version's template type via the HCP API
// resp := client.GetVersion(ctx, bucketName, fingerprint)
// if resp != nil && resp.TemplateType != nil &&
// *resp.TemplateType != currentTemplateType {
// // change fingerprint/bucket or migrate the template before building
// } Try / catch
// Go
if err := bucket.Initialize(ctx); err != nil {
if strings.Contains(err.Error(), "Changing from") {
// template-type conflict: switch template format or use a new bucket/fingerprint
return fmt.Errorf("use a different fingerprint or matching template type: %w", err)
}
return err
} Prevention
- Standardize on one template format (HCL2) per bucket
- Never reuse fingerprints across JSON and HCL2 versions of a template
- When migrating to HCL2, point builds at a new bucket or force a new fingerprint
- Document the template format used per bucket in your team's CI config
When it happens
Trigger: Running packer build against the same bucket+fingerprint that was previously registered by a run using the other template format (e.g. first run with a JSON template, later run with an HCL2 template, or vice versa), with version.TemplateType set and != TEMPLATETYPEUNSET.
Common situations: Migrating templates from legacy JSON to HCL2 while reusing the same fingerprint inputs (identical builds); team members mixing template formats for the same bucket; CI configs updated to HCL2 but reusing an old fingerprinting scheme.
Related errors
- error retrieving version from HCP Packer Registry: %s
- error retrieving channel from HCP Packer Registry: %s
- there is no version associated with the channel %s
- the version %s is revoked and can not be used on Packer buil
- could not find a build result matching [region=%q, platform=
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/e32e0c3c9379ffa0.
Report an issue: GitHub.