{"record":{"id":"f62ef8f14074bfd2","repo":"hashicorp/terraform","slug":"invalid-provider-matching-pattern-q-namespace-ca","errorCode":null,"errorMessage":"invalid provider matching pattern %q: namespace can be a wildcard only if the provider type is also a wildcard","messagePattern":"invalid provider matching pattern %q: namespace can be a wildcard only if the provider type is also a wildcard","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getproviders/multi_source.go","lineNumber":191,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid provider type %q in provider matching pattern %q: must either be the wildcard * or a provider type name\", parts[1], str)\n\t\t}\n\t\tnamespace, err := normalizeProviderNamespaceOrWildcard(parts[0])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid registry namespace %q in provider matching pattern %q: must either be the wildcard * or a literal namespace\", parts[1], str)\n\t\t}\n\n\t\tret[i] = addrs.Provider{\n\t\t\tHostname:  host,\n\t\t\tNamespace: namespace,\n\t\t\tType:      pType,\n\t\t}\n\n\t\tif ret[i].Hostname == svchost.Hostname(Wildcard) && !(ret[i].Namespace == Wildcard && ret[i].Type == Wildcard) {\n\t\t\treturn nil, fmt.Errorf(\"invalid provider matching pattern %q: hostname can be a wildcard only if both namespace and provider type are also wildcards\", str)\n\t\t}\n\t\tif ret[i].Namespace == Wildcard && ret[i].Type != Wildcard {\n\t\t\treturn nil, fmt.Errorf(\"invalid provider matching pattern %q: namespace can be a wildcard only if the provider type is also a wildcard\", str)\n\t\t}\n\t}\n\treturn ret, nil\n}\n\n// CanHandleProvider returns true if and only if the given provider address\n// is both included by the selector's include patterns and _not_ excluded\n// by its exclude patterns.\n//\n// The absense of any include patterns is treated the same as a pattern\n// that matches all addresses. Exclusions take priority over inclusions.\nfunc (s MultiSourceSelector) CanHandleProvider(addr addrs.Provider) bool {\n\tswitch {\n\tcase s.Exclude.MatchesProvider(addr):\n\t\treturn false\n\tcase len(s.Include) > 0:\n\t\treturn s.Include.MatchesProvider(addr)\n\tdefault:","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/getproviders/multi_source.go#L173-L209","documentation":"A wildcard namespace is only legal when the provider type is also a wildcard. \"registry/*/*\" is allowed (matches every provider under every namespace on that host); \"registry/*/aws\" is rejected because wildcarding namespace while pinning type is not a supported selection shape.","triggerScenarios":"Writing a pattern with \"*\" as the namespace but a concrete type, e.g. \"registry.terraform.io/*/aws\" or \"hashicorp/*/aws\". The validator enforces that namespace wildcard implies type wildcard.","commonSituations":"Trying to select \"all namespaces for this provider name\" in a mirror include rule; that granularity is not expressible in the pattern grammar.","solutions":["Wildcard the type as well: \"registry.terraform.io/*/*\".","List each concrete namespace explicitly: \"hashicorp/aws\", \"myorg/aws\", ...","Drop to a two-segment default-registry form if applicable."],"exampleFix":"# before\ninclude = [\"registry.terraform.io/*/aws\"]\n\n# after\ninclude = [\n  \"registry.terraform.io/hashicorp/aws\",\n  \"registry.terraform.io/myorg/aws\",\n]\n# or, to match everything on that host: [\"registry.terraform.io/*/*\"]","handlingStrategy":"validation","validationCode":"// Enforce: namespace wildcard implies type wildcard.\nif parts[len(parts)-2] == \"*\" && parts[len(parts)-1] != \"*\" {\n    return fmt.Errorf(\"namespace wildcard requires type wildcard\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wildcard the type whenever you wildcard the namespace.","List concrete namespaces explicitly for per-type selection.","Use \"host/*/*\" to match all providers on a host."],"tags":["config","validation","pattern","wildcard"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}