{"record":{"id":"0b905f369fb84212","repo":"hashicorp/terraform","slug":"invalid-provider-matching-pattern-q-must-have-ei","errorCode":null,"errorMessage":"invalid provider matching pattern %q: must have either two or three slash-separated segments","messagePattern":"invalid provider matching pattern %q: must have either two or three slash-separated segments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getproviders/multi_source.go","lineNumber":151,"sourceCode":"// The Provider address values in a MultiSourceMatchingPatterns are special in\n// that any of Hostname, Namespace, or Type can be getproviders.Wildcard\n// to indicate that any concrete value is permitted for that segment.\ntype MultiSourceMatchingPatterns []addrs.Provider\n\n// ParseMultiSourceMatchingPatterns parses a slice of strings containing the\n// string form of provider matching patterns and, if all the given strings are\n// valid, returns the corresponding, normalized, MultiSourceMatchingPatterns\n// value.\nfunc ParseMultiSourceMatchingPatterns(strs []string) (MultiSourceMatchingPatterns, error) {\n\tif len(strs) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tret := make(MultiSourceMatchingPatterns, len(strs))\n\tfor i, str := range strs {\n\t\tparts := strings.Split(str, \"/\")\n\t\tif len(parts) < 2 || len(parts) > 3 {\n\t\t\treturn nil, fmt.Errorf(\"invalid provider matching pattern %q: must have either two or three slash-separated segments\", str)\n\t\t}\n\t\thost := defaultRegistryHost\n\t\texplicitHost := len(parts) == 3\n\t\tif explicitHost {\n\t\t\tgivenHost := parts[0]\n\t\t\tif givenHost == \"*\" {\n\t\t\t\thost = svchost.Hostname(Wildcard)\n\t\t\t} else {\n\t\t\t\tnormalHost, err := svchost.ForComparison(givenHost)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"invalid hostname in provider matching pattern %q: %s\", str, err)\n\t\t\t\t}\n\n\t\t\t\t// The remaining code below deals only with the namespace/type portions.\n\t\t\t\thost = normalHost\n\t\t\t}\n\n\t\t\tparts = parts[1:]","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/getproviders/multi_source.go#L133-L169","documentation":"ParseMultiSourceMatchingPatterns splits each pattern on '/' and requires exactly two or three segments. Fewer than two or more than three segments yields this error. Patterns are \"namespace/type\" or \"hostname/namespace/type\"; a bare \"aws\" or \"a/b/c/d\" is invalid.","triggerScenarios":"Passing a string with the wrong number of slash-separated parts, e.g. \"aws\" (one segment), \"hashicorp/aws/extra/here\" (four), or an empty string. Triggered at config load when include/exclude patterns for a provider_installation block are parsed.","commonSituations":"Typing a provider source address without the namespace (\"aws\" instead of \"hashicorp/aws\"); extra trailing slash creating an empty segment; copy-paste of a full provider FQN with a registry path appended.","solutions":["Write the pattern as \"namespace/type\" or \"hostname/namespace/type\".","Remove stray leading/trailing slashes and empty segments.","Use the default-registry short form (\"hashicorp/aws\") when you mean registry.terraform.io."],"exampleFix":"# before\nprovider_installation {\n  network_mirror { url = \"https://m/tf/\" include = [\"aws\"] }\n}\n\n# after\nprovider_installation {\n  network_mirror { url = \"https://m/tf/\" include = [\"hashicorp/aws\"] }\n}","handlingStrategy":"validation","validationCode":"// Validate segment count before parsing patterns.\nparts := strings.Split(p, \"/\")\nif len(parts) < 2 || len(parts) > 3 {\n    return fmt.Errorf(\"pattern %q must have 2 or 3 slash-separated segments\", p)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the \"namespace/type\" or \"hostname/namespace/type\" shape only.","Lint provider_installation include/exclude patterns in CI.","Avoid trailing slashes that create empty segments."],"tags":["config","validation","pattern"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}