{"record":{"id":"89a9405e676ef417","repo":"hashicorp/packer","slug":"invalid-plugin-type-q-in-source-s","errorCode":null,"errorMessage":"Invalid plugin type %q in source: %s\"","messagePattern":"Invalid plugin type %q in source: (.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hcl2template/addrs/plugin.go","lineNumber":159,"sourceCode":"\n\tif url != nil && url.Fragment != \"\" {\n\t\terrs = append(errs, \"A source URL must not contain a fragment (e.g. #anchor).\")\n\t}\n\n\tif errs != nil {\n\t\terrsMsg := &strings.Builder{}\n\t\tfor _, err := range errs {\n\t\t\tfmt.Fprintf(errsMsg, \"* %s\\n\", err)\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\"The provided source URL is invalid.\\nThe following errors have been discovered:\\n%s\\nA valid source looks like \\\"github.com/hashicorp/happycloud\\\"\", errsMsg)\n\t}\n\n\t// check the 'name' portion, which is always the last part\n\t_, givenName := path.Split(str)\n\t_, err = ParsePluginPart(givenName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(`Invalid plugin type %q in source: %s\"`, givenName, err)\n\t}\n\n\t// Due to how plugin executables are named and plugin git repositories\n\t// are conventionally named, it's a reasonable and\n\t// apparently-somewhat-common user error to incorrectly use the\n\t// \"packer-plugin-\" prefix in a plugin source address. There is\n\t// no good reason for a plugin to have the prefix \"packer-\" anyway,\n\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","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/hcl2template/addrs/plugin.go#L141-L177","documentation":"ParsePluginSourceString validates the plugin type (the final path segment of the source) with ParsePluginPart. If it fails, this error reports the invalid type and the underlying reason, with an awkward trailing quote in the message text itself.","triggerScenarios":"Calling ParsePluginSourceString with a source whose last segment contains invalid characters, consecutive dashes, or leading/trailing dashes, e.g. 'github.com/hashicorp/amazon_' or 'github.com/org/--type'.","commonSituations":"Using underscore-separated repo names ('packer_plugin_x'); accidentally leaving the 'packer-plugin-' prefix in the type; copy-paste artifacts in the last segment.","solutions":["Fix the last path segment to contain only letters, digits, and single dashes","Remove any 'packer-plugin-' prefix from the type segment","Re-check the wrapped error text for the exact character problem"],"exampleFix":"// before\nsource = \"github.com/org/packer_plugin_my_data\"  // invalid: underscores\n// after\nsource = \"github.com/org/my-data\"","handlingStrategy":"validation","validationCode":"name := src[strings.LastIndex(src, \"/\")+1:]\nif !regexp.MustCompile(`^[a-zA-Z0-9](-?[a-zA-Z0-9])*$`).MatchString(name) { /* fix type before packer init */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the final path segment a clean identifier (letters, digits, single dashes)","Never append suffixes like '_' or '.git' to the type segment","Test templates with 'packer init' before sharing"],"tags":["validation","plugin-source","hcl2"],"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"}