hashicorp/packer · error
error retrieving version from HCP Packer Registry: %s
Error message
error retrieving version from HCP Packer Registry: %s
What it means
Returned by the hcp-packer-artifact datasource's Execute() when cli.GetVersion() (which queries the HCP Packer Registry for a version identified by version_fingerprint) fails. It wraps the underlying client/HTTP error, so the %s suffix carries the real cause (auth failure, 404, network error, etc.). The datasource returns a null cty value, so the Packer run aborts because the template cannot proceed without the version metadata.
Source
Thrown at datasource/hcp-packer-artifact/data.go:175
ctx := context.TODO()
cli, err := hcpapi.NewClient()
if err != nil {
return cty.NullVal(cty.EmptyObject), err
}
var version *hcpPackerModels.HashicorpCloudPacker20230101Version
var channelID string
if d.config.VersionFingerprint != "" {
log.Printf(
"[INFO] Reading info from HCP Packer Registry (%s) "+
"[project_id=%s, organization_id=%s, version_fingerprint=%s]",
d.config.BucketName, cli.ProjectID, cli.OrganizationID, d.config.VersionFingerprint,
)
version, err = cli.GetVersion(ctx, d.config.BucketName, d.config.VersionFingerprint)
if err != nil {
return cty.NullVal(cty.EmptyObject), fmt.Errorf(
"error retrieving version from HCP Packer Registry: %s", err,
)
}
} else {
log.Printf(
"[INFO] Reading info from HCP Packer Registry (%s) "+
"[project_id=%s, organization_id=%s, channel=%s]",
d.config.BucketName, cli.ProjectID, cli.OrganizationID, d.config.ChannelName,
)
var channel *hcpPackerModels.HashicorpCloudPacker20230101Channel
channel, err = cli.GetChannel(ctx, d.config.BucketName, d.config.ChannelName)
if err != nil {
return cty.NullVal(cty.EmptyObject), fmt.Errorf(
"error retrieving channel from HCP Packer Registry: %s", err.Error(),
)
}
View on GitHub (pinned to eb36e3c3e4)
Solutions
- Verify the version_fingerprint matches an existing version in the bucket (HCP Packer UI or the publishing build's output).
- Confirm HCP_CLIENT_ID and HCP_CLIENT_SECRET are set and valid in the execution environment.
- Check that the HCP project/organization bound to your credentials contains the bucket_name referenced.
- Confirm network access to api.cloud.hashicorp.com (proxy/firewall) and retry transient failures.
- If you just need 'latest', resolve via channel_name instead of a pinned fingerprint.
Example fix
// before
data "hcp-packer-artifact" "foo" {
bucket_name = "my-bucket"
version_fingerprint = "2024-01-01T00:00:00Z" # wrong: fingerprint never published
}
// after
data "hcp-packer-artifact" "foo" {
bucket_name = "my-bucket"
channel_name = "production" # or use the exact fingerprint printed by the publishing build
} Defensive patterns
Strategy: try-catch
Validate before calling
if os.Getenv("HCP_CLIENT_ID") == "" || os.Getenv("HCP_CLIENT_SECRET") == "" {
return fmt.Errorf("HCP credentials must be set before resolving hcp-packer-artifact")
}
if cfg.VersionFingerprint == "" && cfg.ChannelName == "" {
return fmt.Errorf("either version_fingerprint or channel_name must be set")
} Try / catch
// Data source failures abort `packer build`; guard in a wrapper script: if ! packer build template.pkr.hcl; then echo "HCP version lookup failed: check version_fingerprint and HCP credentials" >&2 exit 1 fi
Prevention
- Copy the version_fingerprint verbatim from the publishing build's output or the HCP UI.
- Keep HCP_CLIENT_ID/HCP_CLIENT_SECRET in the environment of every pipeline that resolves the datasource.
- Prefer channel_name over pinned fingerprints so lookups survive version churn.
- Confirm the bucket/project pairing before adding a new datasource reference.
When it happens
Trigger: Execute() runs with version_fingerprint set and cli.GetVersion(ctx, bucket_name, version_fingerprint) errors: fingerprint not in the bucket, missing/invalid HCP_CLIENT_ID/HCP_CLIENT_SECRET, wrong project/organization, misspelled bucket_name, or the registry API is unreachable.
Common situations: Typo in version_fingerprint; fingerprint from a different bucket; expired or missing HCP service-principal credentials in CI; version deleted between publish and consume; corporate proxy blocking api.cloud.hashicorp.com.
Related errors
- error retrieving channel from HCP Packer Registry: %s
- error retrieving image iteration from HCP Packer registry: %
- error retrieving channel from HCP Packer registry: %s
- there is no version associated with the channel %s
- the version %s is revoked and can not be used on Packer buil
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/6fbdd7d5c1ea88df.
Report an issue: GitHub.