{"record":{"id":"5cbec5db173b1668","repo":"hashicorp/packer","slug":"the-provided-source-url-is-invalid-the-following","errorCode":null,"errorMessage":"The provided source URL is invalid.\nThe following errors have been discovered:\n%s\nA valid source looks like \"github.com/hashicorp/happycloud\"","messagePattern":"The provided source URL is invalid\\.\nThe following errors have been discovered:\n(.+?)\nA valid source looks like \"github\\.com/hashicorp/happycloud\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hcl2template/addrs/plugin.go","lineNumber":152,"sourceCode":"\tif url != nil && url.Scheme != \"\" {\n\t\terrs = append(errs, \"A source URL must not contain a scheme (e.g. https://).\")\n\t}\n\n\tif url != nil && url.RawQuery != \"\" {\n\t\terrs = append(errs, \"A source URL must not contain a query (e.g. ?var=val)\")\n\t}\n\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.","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/hcl2template/addrs/plugin.go#L134-L170","documentation":"ParsePluginSourceString aggregates validation failures from all parts of a plugin source address and reports them together. If any part is invalid, it returns this composite error listing each problem as a '* ...' line plus an example of a valid source. It is the top-level validation gate for required_plugins source strings.","triggerScenarios":"Calling ParsePluginSourceString (from decodeRequiredPluginsBlock, installFromServer, or RunContext) with a malformed source like 'not a source!!', 'github.com/', or an address failing host/name parsing.","commonSituations":"Typo'd required_plugins entries in Packer HCL2 templates; empty or truncated source strings; using URL-scheme prefixed addresses ('https://github.com/...'); missing org or name segments.","solutions":["Read the '* ...' sub-errors in the message and fix each listed component","Match the example format 'github.com/hashicorp/happycloud' (host/org/type)","Remove URL schemes, whitespace, and stray characters from the source string"],"exampleFix":"// before\nsource = \"https://github.com/hashicorp/happycloud\"\n// after\nsource = \"github.com/hashicorp/happycloud\"","handlingStrategy":"validation","validationCode":"re := regexp.MustCompile(`^[a-z0-9-]+\\.[a-z0-9-]+/[a-z0-9-]+/[a-z0-9-]+$`) // host/org/type shape\n// check re.MatchString(src) before calling packer init","typeGuard":"func looksLikeSource(s string) bool { return len(strings.Fields(s)) == 1 && strings.Count(s, \"/\") >= 2 && !strings.Contains(s, \"://\") }","tryCatchPattern":"if _, err := addrs.ParsePluginSourceString(src); err != nil {\n  // print err and address each '* ...' sub-line\n}","preventionTips":["Follow the 'github.com/org/type' shape exactly, no scheme, no spaces","Validate template sources in CI before running packer init","Keep one source per required_plugins entry line for clear errors"],"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"}