{"record":{"id":"31b6b1094881b656","repo":"hashicorp/packer","slug":"plugin-source-has-a-type-with-the-prefix-q-which","errorCode":null,"errorMessage":"Plugin source has a type with the prefix %q, which isn't valid.\nAlthough that prefix is often used in the names of version control repositories for Packer plugins, plugin source strings should not include it.\n\nDid you mean %q?","messagePattern":"Plugin source has a type with the prefix %q, which isn't valid\\.\nAlthough that prefix is often used in the names of version control repositories for Packer plugins, plugin source strings should not include it\\.\n\nDid you mean %q\\?","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hcl2template/addrs/plugin.go","lineNumber":185,"sourceCode":"\t// so we've made that invalid from the start both so we can give feedback\n\t// to plugin developers about the packer- prefix being redundant\n\t// and give specialized feedback to folks who incorrectly use the full\n\t// packer-plugin- prefix to help them self-correct.\n\tconst redundantPrefix = \"packer-\"\n\tconst userErrorPrefix = \"packer-plugin-\"\n\tif strings.HasPrefix(givenName, redundantPrefix) {\n\t\tif strings.HasPrefix(givenName, userErrorPrefix) {\n\t\t\t// Likely user error. We only return this specialized error if\n\t\t\t// whatever is after the prefix would otherwise be a\n\t\t\t// syntactically-valid plugin type, so we don't end up advising\n\t\t\t// the user to try something that would be invalid for another\n\t\t\t// reason anyway.\n\t\t\t// (This is mainly just for robustness, because the validation\n\t\t\t// we already did above should've rejected most/all ways for\n\t\t\t// the suggestedType to end up invalid here.)\n\t\t\tsuggestedType := strings.Replace(givenName, userErrorPrefix, \"\", -1)\n\t\t\tif _, err := ParsePluginPart(suggestedType); err == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Plugin source has a type with the prefix %q, which isn't valid.\\n\"+\n\t\t\t\t\t\"Although that prefix is often used in the names of version control repositories \"+\n\t\t\t\t\t\"for Packer plugins, plugin source strings should not include it.\\n\"+\n\t\t\t\t\t\"\\nDid you mean %q?\", userErrorPrefix, suggestedType)\n\t\t\t}\n\t\t}\n\t\t// Otherwise, probably instead an incorrectly-named plugin, perhaps\n\t\t// arising from a similar instinct to what causes there to be\n\t\t// thousands of Python packages on PyPI with \"python-\"-prefixed\n\t\t// names.\n\t\treturn nil, fmt.Errorf(\"Plugin source has a type with the %q prefix, which isn't valid.\\n\"+\n\t\t\t\"If you are the author of this plugin, rename it to not include the prefix.\\n\"+\n\t\t\t\"Ex: %q\",\n\t\t\tredundantPrefix,\n\t\t\tstrings.Replace(givenName, redundantPrefix, \"\", 1))\n\t}\n\n\tplug := &Plugin{\n\t\tSource: str,","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/hcl2template/addrs/plugin.go#L167-L203","documentation":"Packer detects the common mistake of including the 'packer-plugin-' prefix in a source address's type segment. When stripping that prefix yields a valid type, it returns this helpful suggestion error pointing at the corrected source. The check is guarded so the suggestion is only shown when it would itself be valid.","triggerScenarios":"ParsePluginSourceString given e.g. 'github.com/hashicorp/packer-plugin-amazon' where the type segment starts with the 'packer-plugin-' user-error prefix.","commonSituations":"Users naming the source after the git repository ('packer-plugin-docker') instead of the plugin type; copying repo URLs directly into required_plugins.","solutions":["Drop the 'packer-plugin-' prefix from the type segment, as the suggested form in the message shows","Use only the plugin type name, e.g. 'github.com/hashicorp/amazon'","Verify with 'packer init' after the edit"],"exampleFix":"// before\nsource = \"github.com/hashicorp/packer-plugin-amazon\"\n// after\nsource = \"github.com/hashicorp/amazon\"","handlingStrategy":"validation","validationCode":"name := src[strings.LastIndex(src, \"/\")+1:]\nif strings.HasPrefix(name, \"packer-plugin-\") { /* strip prefix before installing */ }","typeGuard":"func hasPackPluginPrefix(s string) bool { return strings.Contains(s, \"/packer-plugin-\") }","tryCatchPattern":null,"preventionTips":["Always strip 'packer-plugin-' when converting repo names to source types","Reference plugins by type, not repository name","Check official docs for canonical source addresses"],"tags":["validation","plugin-source","hcl2","required-plugins"],"backgroundTag":"invalid-plugin-source-address","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"}