{"record":{"id":"55a89df62d2f56d7","repo":"hashicorp/packer","slug":"failed-to-create-version-for-bucket-s-with-error","errorCode":null,"errorMessage":"failed to create Version for Bucket %s with error: %w","messagePattern":"failed to create Version for Bucket (.+?) with error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.bucket.go","lineNumber":457,"sourceCode":"// 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,\n\t)\n\treturn createVersionResp.Payload.Version, nil\n}\n\nfunc (bucket *Bucket) initializeVersion(\n\tctx context.Context, templateType hcpPackerModels.HashicorpCloudPacker20230101TemplateType,\n) error {\n\t// load existing version using fingerprint.\n\tversion, err := bucket.client.GetVersion(ctx, bucket.Name, bucket.Version.Fingerprint)\n\tif hcpPackerAPI.CheckErrorCode(err, codes.Aborted) {","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.bucket.go#L439-L475","documentation":"createVersion calls the HCP Packer registry API to create a Version object for the given bucket. This error wraps whatever failure the API/client returned (network error, auth failure, bucket not found, invalid version name) so the caller initializeVersion can report which bucket failed and why. Check connectivity/credentials to HCP Packer and that the bucket exists and accepts new versions.","triggerScenarios":"Thrown at internal/hcp/registry/types.bucket.go:457 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify HCP credentials and network connectivity, then retry","Check the bucket exists and the fingerprint is valid in HCP Packer"],"exampleFix":null,"handlingStrategy":"retry","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"}