hashicorp/packer · error

packer error: template type should not be unset when…

Error message

packer error: template type should not be unset when creating a version. This is a Packer internal bug which should be reported to the development team for a fix

What it means

Internal assertion in Bucket.createVersion: the template type passed to the HCP version-creation API is TEMPLATETYPEUNSET. Packer failed to classify the template as HCL or JSON upstream — an internal bug, not a user config issue.

Solutions

  1. Report the issue to the Packer maintainers with your template and version
  2. As a workaround, run with HCP disabled (HCP_PACKER_RUN_EMPTY_BUCKET off / remove registry block)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/hcp/registry/types.bucket.go:447 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at internal/hcp/registry/types.bucket.go:447

	// Set some version values. For Packer RunUUID should always be set.
	// Creating an version differently? Let's not overwrite a UUID that might be set.
	if bucket.Version.RunUUID == "" {
		bucket.Version.RunUUID = os.Getenv("PACKER_RUN_UUID")
	}

}

// createVersion creates an empty version for a given bucket on the HCP Packer registry.
// The version can then be stored locally and used for tracking build status and artifacts for a running
// Packer build.
func (bucket *Bucket) createVersion(
	templateType hcpPackerModels.HashicorpCloudPacker20230101TemplateType,
) (*hcpPackerModels.HashicorpCloudPacker20230101Version, error) {
	ctx := context.Background()

	if templateType == hcpPackerModels.HashicorpCloudPacker20230101TemplateTypeTEMPLATETYPEUNSET {
		return nil, fmt.Errorf(
			"packer error: template type should not be unset when creating a version. " +
				"This is a Packer internal bug which should be reported to the development team for a fix",
		)
	}

	createVersionResp, err := bucket.client.CreateVersion(
		ctx, bucket.Name, bucket.Version.Fingerprint, templateType,
	)
	if err != nil {
		return nil, fmt.Errorf("failed to create Version for Bucket %s with error: %w", bucket.Name, err)
	}

	if createVersionResp == nil {
		return nil, fmt.Errorf("failed to create Version for Bucket %s with error: %w", bucket.Name, err)
	}

	log.Println(
		"[TRACE] a valid version for build was created with the Id", createVersionResp.Payload.Version.ID,

View on GitHub (pinned to eb36e3c3e4)