hashicorp/packer · error

the `platform` must be specified

Error message

the `platform` must be specified

What it means

Configuration validation guard in the hcp-packer-artifact datasource's Configure. The datasource resolves an artifact by iteration platform, so it needs to know which platform (e.g. amazon-ebs, vsphere) built the artifact; this sentinel error is appended to a MultiError when the required platform field is empty. Set platform in the datasource block to the builder component type that produced the artifact.

Solutions

  1. Set platform to the OS platform recorded in HCP Packer, e.g. platform = "ubuntu" or "amazon-linux"
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at datasource/hcp-packer-artifact/data.go:98 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at datasource/hcp-packer-artifact/data.go:98

	if d.config.ChannelName == "" && d.config.VersionFingerprint == "" {
		errs = packersdk.MultiErrorAppend(errs, errors.New(
			"`version_fingerprint` or `channel_name` must be specified",
		))
	}
	if d.config.ChannelName != "" && d.config.VersionFingerprint != "" {
		errs = packersdk.MultiErrorAppend(errs, errors.New(
			"`version_fingerprint` and `channel_name` cannot be specified together",
		))
	}

	if d.config.Region == "" {
		errs = packersdk.MultiErrorAppend(errs,
			fmt.Errorf("the `region` must be specified"),
		)
	}

	if d.config.Platform == "" {
		errs = packersdk.MultiErrorAppend(errs, fmt.Errorf(
			"the `platform` must be specified",
		))
	}

	if errs != nil && len(errs.Errors) > 0 {
		return errs
	}
	return nil
}

// DatasourceOutput Information from []*hcpPackerModels.HashicorpCloudPacker20230101Artifact with some information
// from the parent []*hcpPackerModels.HashicorpCloudPacker20230101Build included where it seemed
// like it might be relevant. Need to copy so we can generate
type DatasourceOutput struct {
	// The name of the platform that the artifact exists in.
	// For example, "aws", "azure", or "gce".
	Platform string `mapstructure:"platform"`

View on GitHub (pinned to eb36e3c3e4)