hashicorp/packer · error

wrong version: %s does not match expected %s

Error message

wrong version: %s does not match expected %s

What it means

Validate() checks that a checksum-file entry's parsed binary version (entry.BinVersion, e.g. "v1.2.3") matches the version constraint the user requested, prefixed with "v". A mismatch means the entry being validated belongs to a different release than the one being installed.

Source

Thrown at packer/plugin-getter/github/getter.go:324

	res = strings.TrimSuffix(res, entry.Ext)
	// res now looks like v0.2.12_x5.0_freebsd_amd64

	parts := strings.Split(res, "_")
	// ["v0.2.12", "x5.0", "freebsd", "amd64"]
	if len(parts) < 4 {
		return fmt.Errorf("malformed filename expected %s{version}_x{protocol-version}_{os}_{arch}", req.FilenamePrefix())
	}

	entry.BinVersion, entry.ProtVersion, entry.Os, entry.Arch = parts[0], parts[1], parts[2], parts[3]

	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)
	}
	if entry.Os != installOpts.OS || entry.Arch != installOpts.ARCH {
		return fmt.Errorf("wrong system, expected %s_%s", installOpts.OS, installOpts.ARCH)
	}

	return installOpts.CheckProtocolVersion(entry.ProtVersion)
}

func (g *Getter) ExpectedFileName(pr *plugingetter.Requirement, version string, entry *plugingetter.ChecksumFileEntry, _ string) string {
	pluginSourceParts := strings.Split(pr.Identifier.Source, "/")
	return strings.Join([]string{
		"packer-plugin-" + pluginSourceParts[2],
		entry.BinVersion,
		entry.ProtVersion,
		entry.Os,
		entry.Arch + entry.Ext,
	}, "_")
}

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Align the requested version constraint in required_plugins with a version that actually exists in the plugin's releases (run `packer plugins installed` or check GitHub releases).
  2. Ensure release assets and SHA256SUM entries carry versions with a consistent "v" prefix matching the git tag.
  3. Regenerate the checksum file so every entry corresponds to the released version.

Example fix

// before (required_plugins)
myplug = { version = "= 1.2.3", source = "github.com/foo/myplug" }
// after
myplug = { version = "= 1.2.4", source = "github.com/foo/myplug" }
Defensive patterns

Strategy: validation

Validate before calling

expected := "v" + reqVersion
if entry.BinVersion != expected {
	return fmt.Errorf("entry %s != requested %s", entry.BinVersion, expected)
}

Type guard

func entryMatchesVersion(entry *plugingetter.ChecksumFileEntry, expectedVersion string) bool {
	return entry != nil && entry.BinVersion == "v"+expectedVersion
}

Try / catch

if err := g.Validate(opt, ver, installOpts, entry); err != nil {
	if strings.HasPrefix(err.Error(), "wrong version") {
		// try the next checksum entry matching the constraint
	}
}

Prevention

When it happens

Trigger: Getter.Validate() is called with expectedVersion="1.2.3" but entry.BinVersion is e.g. "v1.2.4" — i.e. the checksum entry parsed from the releases file has a version string that differs (including missing or extra 'v', or a prerelease suffix) from the requested requirement version.

Common situations: required_plugins pins "= 1.2.3" but the latest checksum entry picked is 1.2.4; versions listed in the checksum file inconsistently use or omit the "v" prefix; a stale/mismatched SHA256SUM file accompanies a newer release.

Related errors


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