hashicorp/packer · error
Plugin source has a type with the %q prefix, which isn't val
Error message
Plugin source has a type with the %q prefix, which isn't valid. If you are the author of this plugin, rename it to not include the prefix. Ex: %q
What it means
When a type segment starts with a redundant prefix (like 'packer-plugin-' or 'packer-provisioner-') that would NOT produce a valid suggestion via ParsePluginPart, Packer still rejects it, telling plugin authors to rename rather than offering a suggestion. This covers prefixes that leave an invalid remainder (e.g. residual underscores).
Source
Thrown at hcl2template/addrs/plugin.go:195
// 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,
}
if len(plug.Parts()) > 16 {
return nil, fmt.Errorf("The source URL must have at most 16 components, and the one provided has %d.\n"+
"This is unsupported by Packer, please consider using a source that has less components to it.\n"+
"If this is a blocking issue for you, please open an issue to ask for supporting more "+
"components to the source URI.",
len(plug.Parts()))
}
return plug, nilView on GitHub (pinned to eb36e3c3e4)
Solutions
- If you are the plugin author, rename the plugin/repository to drop the prefix and use only letters, digits, and single dashes
- If you are a user, pin an older release or ask the author to rename; then reference the corrected type
- Strip the prefix manually and validate the remaining type characters yourself
Example fix
// before source = "github.com/org/packer-plugin-my_data" // after source = "github.com/org/my-data"
Defensive patterns
Strategy: validation
Validate before calling
name := src[strings.LastIndex(src, "/")+1:]
for _, p := range []string{"packer-plugin-", "packer-provisioner-", "packer-builder-"} {
if strings.HasPrefix(name, p) { name = strings.TrimPrefix(name, p) }
}
// validate name has only [a-zA-Z0-9-] before use Prevention
- Plugin authors: name repos 'packer-plugin-<type>' and publish the type without the prefix
- Sanitize renamed plugins to valid identifiers
- Document the canonical source string in your plugin README
When it happens
Trigger: ParsePluginSourceString given a type with a redundant component prefix whose stripped result still fails validation, e.g. 'github.com/org/packer-plugin-my_data'.
Common situations: Plugin authors who published repos with prefix plus invalid characters (underscores); users referencing such badly-named plugins.
Related errors
- cannot use multiple consecutive dashes
- must contain only letters, digits, and dashes, and may not u
- The provided source URL is invalid. The following errors hav
- Invalid plugin type %q in source: %s"
- Plugin source has a type with the prefix %q, which isn't val
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/94bf10f96953e132.
Report an issue: GitHub.