hashicorp/packer · error

something went wrong retrieving the version for bucket %s

Error message

something went wrong retrieving the version for bucket %s

What it means

GetVersion fetches a specific version (by fingerprint) of a bucket from HCP Packer; when the API call succeeds but resp.Payload.Version is nil, it throws this error. It is called from initializeVersion when builders/datasources resolve a bucket version, meaning the requested version was not returned by the service.

Source

Thrown at internal/hcp/api/service_version.go:60

func (c *Client) GetVersion(
	ctx context.Context, bucketName string, fingerprint string,
) (*hcpPackerModels.HashicorpCloudPacker20230101Version, error) {
	params := hcpPackerAPI.NewPackerServiceGetVersionParams()
	params.LocationOrganizationID = c.OrganizationID
	params.LocationProjectID = c.ProjectID
	params.BucketName = bucketName
	params.Fingerprint = fingerprint

	resp, err := c.Packer.PackerServiceGetVersion(params, nil)
	if err != nil {
		return nil, err
	}

	if resp.Payload.Version != nil {
		return resp.Payload.Version, nil
	}

	return nil, fmt.Errorf(
		"something went wrong retrieving the version for bucket %s", bucketName,
	)
}

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Verify the bucket name and version fingerprint in the HCP Packer registry.
  2. Check whether the version was soft-deleted/garbage collected and restore or revoke it properly.
  3. Ensure the version's builds completed and were published before referencing it.
  4. Re-run the source build to publish a fresh version/fingerprint.

Example fix

// before
version, err := client.GetVersion(ctx, "my-bucket", staleFingerprint) // purged version
// after
// re-run the builder to publish a new version, then use its fingerprint
version, err := client.GetVersion(ctx, "my-bucket", newFingerprint)
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the version is published and not revoked before use
if !versionIsPublished(registry, bucketName, fingerprint) {
    return fmt.Errorf("version %s not published for bucket %s", fingerprint, bucketName)
}

Try / catch

version, err := client.GetVersion(ctx, bucketName, fingerprint)
if err != nil {
    if strings.Contains(err.Error(), "something went wrong retrieving the version") {
        return fmt.Errorf("version %q missing in bucket %q (purged or unpublished)", fingerprint, bucketName)
    }
    return err
}

Prevention

When it happens

Trigger: PackerServiceGetVersion succeeds but resp.Payload.Version == nil — the fingerprint/version does not exist or is not visible for bucketName.

Common situations: Referencing a version fingerprint that was soft-deleted by HCP Packer's 90-day incomplete-version GC; wrong bucket name; version not yet published (build still running); revoked version restored incorrectly.

Related errors


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/cb43e26ff215c273. Report an issue: GitHub.