{"record":{"id":"e4d2e72bdfd85795","repo":"hashicorp/packer","slug":"packer-error-template-type-should-not-be-unset-wh","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.bucket.go","lineNumber":447,"sourceCode":"\n\t// Set some version values. For Packer RunUUID should always be set.\n\t// Creating an version differently? Let's not overwrite a UUID that might be set.\n\tif bucket.Version.RunUUID == \"\" {\n\t\tbucket.Version.RunUUID = os.Getenv(\"PACKER_RUN_UUID\")\n\t}\n\n}\n\n// createVersion creates an empty version for a given bucket on the HCP Packer registry.\n// The version can then be stored locally and used for tracking build status and artifacts for a running\n// Packer build.\nfunc (bucket *Bucket) createVersion(\n\ttemplateType hcpPackerModels.HashicorpCloudPacker20230101TemplateType,\n) (*hcpPackerModels.HashicorpCloudPacker20230101Version, error) {\n\tctx := context.Background()\n\n\tif templateType == hcpPackerModels.HashicorpCloudPacker20230101TemplateTypeTEMPLATETYPEUNSET {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"packer error: template type should not be unset when creating a version. \" +\n\t\t\t\t\"This is a Packer internal bug which should be reported to the development team for a fix\",\n\t\t)\n\t}\n\n\tcreateVersionResp, err := bucket.client.CreateVersion(\n\t\tctx, bucket.Name, bucket.Version.Fingerprint, templateType,\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create Version for Bucket %s with error: %w\", bucket.Name, err)\n\t}\n\n\tif createVersionResp == nil {\n\t\treturn nil, fmt.Errorf(\"failed to create Version for Bucket %s with error: %w\", bucket.Name, err)\n\t}\n\n\tlog.Println(\n\t\t\"[TRACE] a valid version for build was created with the Id\", createVersionResp.Payload.Version.ID,","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.bucket.go#L429-L465","documentation":"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.","triggerScenarios":"Thrown at internal/hcp/registry/types.bucket.go:447 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report the issue to the Packer maintainers with your template and version","As a workaround, run with HCP disabled (HCP_PACKER_RUN_EMPTY_BUCKET off / remove registry block)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}