{"record":{"id":"12202dcb169ab3fc","repo":"hashicorp/packer","slug":"malformed-filename-expected-s-version-os-arch","errorCode":null,"errorMessage":"malformed filename expected %s{version}_{os}_{arch}","messagePattern":"malformed filename expected (.+?)(.+?)_(.+?)_(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packer/plugin-getter/release/getter.go","lineNumber":149,"sourceCode":"\n// Init method : a file inside will look like so:\n//\n//\tpacker-plugin-comment_0.2.12_freebsd_amd64.zip\nfunc (g *Getter) Init(req *plugingetter.Requirement, entry *plugingetter.ChecksumFileEntry) error {\n\tfilename := entry.Filename\n\t//remove the test line below where hardcoded prefix being used\n\tres := strings.TrimPrefix(filename, req.FilenamePrefix())\n\t// res now looks like v0.2.12_freebsd_amd64.zip\n\n\tentry.Ext = filepath.Ext(res)\n\n\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)","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/packer/plugin-getter/release/getter.go#L131-L167","documentation":"Init parses a downloaded plugin binary's filename to extract version, OS, and arch, expecting the naming scheme {prefix}_{version}_{os}_{arch}[_ext] (e.g. packer-plugin-docker_1.1.1_freebsd_amd64.zip). If after stripping the extension the underscore-split yields fewer than 3 parts, the filename does not follow the official plugin naming convention and Init fails.","triggerScenarios":"Getter.Init is given a ChecksumFileEntry whose Filename, after removing the prefix and extension and splitting on \"_\", has fewer than 3 segments — e.g. \"packer-plugin-docker_1.1.1.zip\" (no os/arch) or a bare version string.","commonSituations":"Manually downloaded or self-renamed plugin binaries placed in PACKER_PLUGIN_PATH; third-party plugin releases that don't follow HashiCorp's naming convention; old/custom plugin builds produced before the standardized naming scheme.","solutions":["Rename the plugin file to the canonical form {prefix}_{version}_{os}_{arch}.zip (e.g. packer-plugin-docker_1.1.1_linux_amd64.zip).","Re-download the plugin via `packer plugins install` so the officially named release zip is used.","If it's a custom plugin, update its release pipeline to emit HashiCorp-convention filenames."],"exampleFix":"// before (file on disk)\npacker-plugin-docker_1.1.1.zip\n// after\npacker-plugin-docker_1.1.1_linux_amd64.zip","handlingStrategy":"validation","validationCode":"name := strings.TrimSuffix(filepath.Base(filename), filepath.Ext(filename))\nparts := strings.Split(name, \"_\")\nif len(parts) < 3 {\n    return fmt.Errorf(\"rename %q to prefix_version_os_arch before installing\", filename)\n}","typeGuard":null,"tryCatchPattern":"if err := g.Init(req, opts); err != nil {\n    if strings.HasPrefix(err.Error(), \"malformed filename\") {\n        // rename the binary to the canonical scheme and retry once\n    }\n}","preventionTips":["Always install plugins via `packer plugins install`, never by manually renaming binaries.","Keep plugin release pipelines emitting HashiCorp-convention filenames."],"tags":["packer","plugin-getter","filename-parsing","naming-convention"],"backgroundTag":"malformed-filename","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"}