{"record":{"id":"171a0a841ed3ad40","repo":"hashicorp/packer","slug":"error-retrieving-channel-from-hcp-packer-registry","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-artifact/data.go","lineNumber":189,"sourceCode":"\t\t)\n\n\t\tversion, err = cli.GetVersion(ctx, d.config.BucketName, d.config.VersionFingerprint)\n\t\tif err != nil {\n\t\t\treturn cty.NullVal(cty.EmptyObject), fmt.Errorf(\n\t\t\t\t\"error retrieving version from HCP Packer Registry: %s\", err,\n\t\t\t)\n\t\t}\n\t} else {\n\t\tlog.Printf(\n\t\t\t\"[INFO] Reading info from HCP Packer Registry (%s) \"+\n\t\t\t\t\"[project_id=%s, organization_id=%s, channel=%s]\",\n\t\t\td.config.BucketName, cli.ProjectID, cli.OrganizationID, d.config.ChannelName,\n\t\t)\n\n\t\tvar channel *hcpPackerModels.HashicorpCloudPacker20230101Channel\n\t\tchannel, err = cli.GetChannel(ctx, d.config.BucketName, d.config.ChannelName)\n\t\tif err != nil {\n\t\t\treturn cty.NullVal(cty.EmptyObject), fmt.Errorf(\n\t\t\t\t\"error retrieving channel from HCP Packer Registry: %s\", err.Error(),\n\t\t\t)\n\t\t}\n\n\t\tif channel.Version == nil {\n\t\t\treturn cty.NullVal(cty.EmptyObject), fmt.Errorf(\n\t\t\t\t\"there is no version associated with the channel %s\", d.config.ChannelName,\n\t\t\t)\n\t\t}\n\t\tchannelID = channel.ID\n\t\tversion = channel.Version\n\t}\n\n\tif *version.Status == hcpPackerModels.HashicorpCloudPacker20230101VersionStatusVERSIONREVOKED {\n\t\treturn cty.NullVal(cty.EmptyObject), fmt.Errorf(\n\t\t\t\"the version %s is revoked and can not be used on Packer builds\", version.ID,\n\t\t)\n\t}","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-artifact/data.go#L171-L207","documentation":"Returned by the hcp-packer-artifact datasource when cli.GetChannel() fails while resolving channel_name against the HCP Packer Registry. The wrapped err.Error() is included, so the real cause (404 channel not found, auth failure, network error) is visible. Execute() returns a null cty value and the Packer build stops.","triggerScenarios":"Execute() runs with channel_name set (no version_fingerprint) and GetChannel(ctx, bucket_name, channel_name) errors: channel does not exist in the bucket, bucket/project is wrong, HCP credentials invalid/missing, or the API call fails (4xx/5xx, timeout, DNS).","commonSituations":"Misspelled channel name ('prod' vs 'production'); channel never created; channel belongs to another project; missing HCP_CLIENT_ID/HCP_CLIENT_SECRET in CI; transient HCP API outage.","solutions":["Verify the channel exists in the bucket in the HCP Packer UI and the name matches exactly (case-sensitive).","Confirm bucket_name and the HCP project/organization bound to your credentials are correct.","Ensure HCP_CLIENT_ID and HCP_CLIENT_SECRET are present and valid.","Retry on transient network/5xx errors; check status.cloud.hashicorp.com for outages."],"exampleFix":"// before\ndata \"hcp-packer-artifact\" \"foo\" {\n  bucket_name = \"my-bucket\"\n  channel_name = \"prod\" # channel is actually named \"production\"\n}\n// after\ndata \"hcp-packer-artifact\" \"foo\" {\n  bucket_name = \"my-bucket\"\n  channel_name = \"production\"\n}","handlingStrategy":"validation","validationCode":"func validateArtifactDatasource(bucket, channel string) error {\n    if channel == \"\" {\n        return fmt.Errorf(\"channel_name required when version_fingerprint is not used\")\n    }\n    if bucket == \"\" {\n        return fmt.Errorf(\"bucket_name required\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"try {\n  packer build template.pkr.hcl\n} catch (err) {\n  if (String(err).includes(\"error retrieving channel from HCP Packer Registry\")) {\n    console.error(\"Channel/bucket mismatch or HCP auth failure — verify channel name and credentials\");\n  }\n  throw err;\n}","preventionTips":["Name channels consistently (e.g. production, staging) and document them per bucket.","Lint templates to ensure channel_name references match created channels.","Verify HCP credentials exist before running builds that resolve channels."],"tags":["hcp-packer","http-client","registry-lookup","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"}