{"record":{"id":"f68523694d123700","repo":"hashicorp/packer","slug":"wrong-version-s-does-not-match-expected-s-f68523","errorCode":null,"errorMessage":"wrong version: %s does not match expected %s","messagePattern":"wrong version: (.+?) does not match expected (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packer/plugin-getter/release/getter.go","lineNumber":161,"sourceCode":"\tres = strings.TrimSuffix(res, entry.Ext)\n\t// res now looks like 0.2.12_freebsd_amd64\n\n\tparts := strings.Split(res, \"_\")\n\t// [\"0.2.12\", \"freebsd\", \"amd64\"]\n\tif len(parts) < 3 {\n\t\treturn fmt.Errorf(\"malformed filename expected %s{version}_{os}_{arch}\", req.FilenamePrefix())\n\t}\n\n\tentry.BinVersion, entry.Os, entry.Arch = parts[0], parts[1], parts[2]\n\tentry.BinVersion = strings.TrimPrefix(entry.BinVersion, \"v\")\n\n\treturn nil\n}\n\nfunc (g *Getter) Validate(opt plugingetter.GetOptions, expectedVersion string, installOpts plugingetter.BinaryInstallationOptions, entry *plugingetter.ChecksumFileEntry) error {\n\n\tif entry.BinVersion != expectedVersion {\n\t\treturn fmt.Errorf(\"wrong version: %s does not match expected %s\", entry.BinVersion, expectedVersion)\n\t}\n\tif entry.Os != installOpts.OS || entry.Arch != installOpts.ARCH {\n\t\treturn fmt.Errorf(\"wrong system, expected %s_%s got %s_%s\", installOpts.OS, installOpts.ARCH, entry.Os, entry.Arch)\n\t}\n\n\tmanifest, err := g.Get(\"meta\", opt)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar data plugingetter.ManifestMeta\n\tbody, err := io.ReadAll(manifest)\n\tif err != nil {\n\t\tlog.Printf(\"Failed to unmarshal manifest json: %s\", err)\n\t\treturn err\n\t}\n\n\terr = json.Unmarshal(body, &data)","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/packer/plugin-getter/release/getter.go#L143-L179","documentation":"Validate cross-checks a parsed ChecksumFileEntry against the version constraint the installer expects. If the version embedded in the downloaded binary's filename (entry.BinVersion) differs from expectedVersion, the downloaded release is not the requested one and validation fails before the binary is trusted.","triggerScenarios":"Getter.Validate called with an entry whose BinVersion (parsed from the filename) does not equal expectedVersion — e.g. expected \"1.1.1\" but the entry filename says \"v1.1.1\" handled elsewhere, or a cached/stale checksum file lists an older version like 1.0.0.","commonSituations":"Pinning a plugin version in required_plugins while a stale checksum/index cache still points at an old release; a plugin re-released under the same tag with rebuilt binaries; manually mixing plugin files of different versions in the plugin directory.","solutions":["Re-run `packer plugins install` (or delete the plugin cache dir) so files matching the required version are fetched fresh.","Verify the version constraint in the HCL2 required_plugins block matches the version of the binary actually downloaded.","Check releases.hashicorp.com to confirm the expected version exists and its assets use the correct version string in filenames."],"exampleFix":"// before (required_plugins block)\ndocker = {\n  version = \"= 1.0.0\"\n}\n// after\ndocker = {\n  version = \"= 1.1.1\"\n}","handlingStrategy":"validation","validationCode":"if entry.BinVersion != expectedVersion {\n    // clear plugin cache and reinstall before proceeding\n    os.RemoveAll(pluginDir)\n}","typeGuard":null,"tryCatchPattern":"if err := g.Validate(opt, expectedVersion, installOpts, entry); err != nil {\n    if strings.Contains(err.Error(), \"wrong version\") {\n        // purge cache, re-run `packer plugins install`, retry\n    }\n}","preventionTips":["Pin plugin versions explicitly in required_plugins and keep them in sync with installed binaries.","Clear PACKER_PLUGIN_PATH contents after upgrading version constraints.","Never mix plugin binaries from different versions in one directory."],"tags":["packer","plugin-getter","version-mismatch","validation"],"backgroundTag":"version-mismatch","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}