hashicorp/packer · error
Plugin source has a type with the prefix
Error message
Plugin source has a type with the prefix %q, which isn't valid. Although that prefix is often used in the names of version control repositories for Packer plugins, plugin source strings should not include it. Did you mean %q?
What it means
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.
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
Example fix
// before source = "github.com/hashicorp/packer-plugin-amazon" // after source = "github.com/hashicorp/amazon"
Defensive patterns
Strategy: validation
Validate before calling
name := src[strings.LastIndex(src, "/")+1:]
if strings.HasPrefix(name, "packer-plugin-") { /* strip prefix before installing */ } Type guard
func hasPackPluginPrefix(s string) bool { return strings.Contains(s, "/packer-plugin-") } Prevention
- 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
When it happens
Trigger: ParsePluginSourceString given e.g. 'github.com/hashicorp/packer-plugin-amazon' where the type segment starts with the 'packer-plugin-' user-error prefix.
Common situations: Users naming the source after the git repository ('packer-plugin-docker') instead of the plugin type; copying repo URLs directly into required_plugins.
Related errors
- The provided source URL is invalid. The following errors…
- cannot use multiple consecutive dashes
- Invalid plugin type in source
- must contain only letters, digits, and dashes, and may not…
- Plugin source has a type with the
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/31b6b1094881b656.
Report an issue: GitHub.
Appendix: source
Thrown at hcl2template/addrs/plugin.go:185
// so we've made that invalid from the start both so we can give feedback
// to plugin developers about the packer- prefix being redundant
// and give specialized feedback to folks who incorrectly use the full
// packer-plugin- prefix to help them self-correct.
const redundantPrefix = "packer-"
const userErrorPrefix = "packer-plugin-"
if strings.HasPrefix(givenName, redundantPrefix) {
if strings.HasPrefix(givenName, userErrorPrefix) {
// Likely user error. We only return this specialized error if
// whatever is after the prefix would otherwise be a
// syntactically-valid plugin type, so we don't end up advising
// the user to try something that would be invalid for another
// reason anyway.
// (This is mainly just for robustness, because the validation
// we already did above should've rejected most/all ways for
// the suggestedType to end up invalid here.)
suggestedType := strings.Replace(givenName, userErrorPrefix, "", -1)
if _, err := ParsePluginPart(suggestedType); err == nil {
return nil, fmt.Errorf("Plugin source has a type with the prefix %q, which isn't valid.\n"+
"Although 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?", userErrorPrefix, suggestedType)
}
}
// Otherwise, probably instead an incorrectly-named plugin, perhaps
// arising from a similar instinct to what causes there to be
// thousands of Python packages on PyPI with "python-"-prefixed
// names.
return nil, fmt.Errorf("Plugin source has a type with the %q prefix, which isn't valid.\n"+
"If you are the author of this plugin, rename it to not include the prefix.\n"+
"Ex: %q",
redundantPrefix,
strings.Replace(givenName, redundantPrefix, "", 1))
}
plug := &Plugin{
Source: str,View on GitHub (pinned to eb36e3c3e4)