hashicorp/packer · error

malformed filename %s: version %q must have a v prefix along

Error message

malformed filename %s: version %q must have a v prefix alongside a protocol version

What it means

Remote getter error from Init: a checksum-file entry uses the GitHub-style name with a protocol version (e.g. ..._v0.2.12_x5.0_...), but the version token lacks the required 'v' prefix, so the filename cannot be parsed into version/protocol parts.

Source

Thrown at packer/plugin-getter/remote/getter.go:283

// Init parses a checksum-file entry name in either accepted shape:
//
//	packer-plugin-comment_v0.2.12_x5.0_freebsd_amd64.zip  (GitHub release asset)
//	packer-plugin-docker_1.1.4_darwin_arm64.zip           (releases.hashicorp.com)
//
// The releases.hashicorp.com shape carries no protocol version; Validate
// fills it from the version's manifest.json.
func (g *Getter) Init(req *plugingetter.Requirement, entry *plugingetter.ChecksumFileEntry) error {
	filename := entry.Filename
	res := strings.TrimPrefix(filename, req.FilenamePrefix())

	entry.Ext = filepath.Ext(res)
	res = strings.TrimSuffix(res, entry.Ext)

	parts := strings.Split(res, "_")
	switch {
	case len(parts) >= 4 && protocolVersionRe.MatchString(parts[1]):
		if !strings.HasPrefix(parts[0], "v") {
			return fmt.Errorf("malformed filename %s: version %q must have a v prefix alongside a protocol version", filename, parts[0])
		}
		entry.BinVersion, entry.ProtVersion, entry.Os, entry.Arch = parts[0], parts[1], parts[2], parts[3]
	case len(parts) == 3 && !strings.HasPrefix(parts[0], "v"):
		entry.BinVersion, entry.Os, entry.Arch = "v"+parts[0], parts[1], parts[2]
		entry.ProtVersion = ""
	default:
		return fmt.Errorf(
			"malformed filename %s: expected %s{version}_x{protocol-version}_{os}_{arch} or %s{version}_{os}_{arch}",
			filename, req.FilenamePrefix(), req.FilenamePrefix())
	}

	return nil
}

func (g *Getter) Validate(opt plugingetter.GetOptions, expectedVersion string, installOpts plugingetter.BinaryInstallationOptions, entry *plugingetter.ChecksumFileEntry) error {
	expectedBinVersion := "v" + expectedVersion
	if entry.BinVersion != expectedBinVersion {
		return fmt.Errorf("wrong version: %s does not match expected %s", entry.BinVersion, expectedBinVersion)

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Fix the checksum entry's filename to include the v prefix on the version (v1.2.3 not 1.2.3) when a protocol version is embedded
  2. Regenerate/republish the checksum file with correctly named assets
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packer/plugin-getter/remote/getter.go:283 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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