{"record":{"id":"f589e1d8c463f098","repo":"hashicorp/packer","slug":"error-retrieving-channel-from-hcp-packer-registry-f589e1","errorCode":null,"errorMessage":"error retrieving channel from HCP Packer registry: %s","messagePattern":"error retrieving channel from HCP Packer registry: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"datasource/hcp-packer-image/data.go","lineNumber":171,"sourceCode":"\tvar channelID string\n\tif d.config.IterationID != \"\" {\n\t\tlog.Printf(\"[INFO] Reading info from HCP Packer registry (%s) [project_id=%s, organization_id=%s, iteration_id=%s]\",\n\t\t\td.config.Bucket, cli.ProjectID, cli.OrganizationID, d.config.IterationID)\n\n\t\titer, err := cli.GetIteration(ctx, d.config.Bucket, hcpapi.GetIteration_byID(d.config.IterationID))\n\t\tif err != nil {\n\t\t\treturn cty.NullVal(cty.EmptyObject), fmt.Errorf(\n\t\t\t\t\"error retrieving image iteration from HCP Packer registry: %s\",\n\t\t\t\terr)\n\t\t}\n\t\titeration = iter\n\t} else {\n\t\tlog.Printf(\"[INFO] Reading info from HCP Packer registry (%s) [project_id=%s, organization_id=%s, channel=%s]\",\n\t\t\td.config.Bucket, cli.ProjectID, cli.OrganizationID, d.config.Channel)\n\n\t\tchannel, err := cli.GetChannel(ctx, d.config.Bucket, d.config.Channel)\n\t\tif err != nil {\n\t\t\treturn cty.NullVal(cty.EmptyObject), fmt.Errorf(\"error retrieving \"+\n\t\t\t\t\"channel from HCP Packer registry: %s\", err.Error())\n\t\t}\n\n\t\tif channel.Iteration == nil {\n\t\t\treturn cty.NullVal(cty.EmptyObject), fmt.Errorf(\"there is no iteration associated with the channel %s\",\n\t\t\t\td.config.Channel)\n\t\t}\n\t\tchannelID = channel.ID\n\t\titeration = channel.Iteration\n\t}\n\n\trevokeAt := time.Time(iteration.RevokeAt)\n\tif !revokeAt.IsZero() && revokeAt.Before(time.Now().UTC()) {\n\t\t// If RevokeAt is not a zero date and is before NOW, it means this iteration is revoked and should not be used\n\t\t// to build new images.\n\t\treturn cty.NullVal(cty.EmptyObject), fmt.Errorf(\"the iteration %s is revoked and can not be used on Packer builds\",\n\t\t\titeration.ID)\n\t}","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-image/data.go#L153-L189","documentation":"Returned by the hcp-packer-image datasource's Execute() when cli.GetChannel() fails while resolving the configured channel. The wrapped err.Error() carries the true cause (channel not found, auth failure, network error). Execution aborts with a null cty output because the iteration cannot be resolved without a successful channel lookup.","triggerScenarios":"channel is set (no iteration_id) and GetChannel(ctx, bucket, channel) returns an error: channel does not exist in the bucket, bucket/project is wrong, HCP credentials missing/invalid, or the deprecated registry API call fails (404/401/5xx/timeout).","commonSituations":"Misspelled channel name; channel created in a different project; CI missing HCP credentials; legacy datasource pointing at deprecated endpoints for newer registries; transient HCP outage mid-pipeline.","solutions":["Verify the channel name exists in the bucket (case-sensitive) in the HCP Packer UI.","Confirm bucket_name and the HCP project/organization of your credentials are correct.","Set/refresh HCP_CLIENT_ID and HCP_CLIENT_SECRET in the execution environment.","Retry on transient network/5xx errors, and migrate to hcp-packer-artifact since this datasource is deprecated."],"exampleFix":"// before\ndata \"hcp-packer-image\" \"example\" {\n  bucket_name = \"my-bucket\"\n  channel = \"prod\" # actual channel is \"production\"\n  region = \"us-east-1\"\n  cloud_provider = \"aws\"\n}\n// after\ndata \"hcp-packer-image\" \"example\" {\n  bucket_name = \"my-bucket\"\n  channel = \"production\"\n  region = \"us-east-1\"\n  cloud_provider = \"aws\"\n}","handlingStrategy":"validation","validationCode":"# Pre-check credentials and channel existence before invoking packer:\ntest -n \"$HCP_CLIENT_ID\" && test -n \"$HCP_CLIENT_SECRET\" || { echo \"HCP credentials missing\"; exit 1; }\n# verify the channel exists in the configured bucket via the HCP UI/API before build","typeGuard":null,"tryCatchPattern":"if ! packer build template.pkr.hcl; then\n  if packer_logs | grep -q 'error retrieving channel from HCP Packer registry'; then\n    echo \"Check channel name, bucket/project, and HCP credentials\" >&2\n  fi\n  exit 1\nfi","preventionTips":["Standardize channel names across buckets and verify them in the HCP UI.","Ensure HCP credentials are provisioned in all CI environments.","Plan migration to hcp-packer-artifact, since hcp-packer-image is deprecated."],"tags":["hcp-packer","http-client","registry-lookup","deprecated-datasource"],"backgroundTag":"hcp-registry-lookup-failed","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"}