{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/getproviders/multi_source.go#L173-L209","documentation":"Thrown when the namespace is the wildcard '*' but the type is not also '*'. The model only allows a wildcard namespace together with a wildcard type (i.e. 'host/*/*' or '*/*'); wildcarding the namespace while pinning a concrete type is not a meaningful selector and is rejected at multi_source.go:190-191.","triggerScenarios":"Patterns like '*/aws', 'host/*/aws', or 'registry.terraform.io/*/aws'. Any pattern (2- or 3-segment) where the namespace is '*' but the final type segment is a literal name.","commonSituations":"Trying to express 'this provider type from any namespace' — not supported; copy-paste turning a namespace into '*' while leaving the type concrete; building include patterns intending broad namespace coverage for one provider.","solutions":["If you want a concrete provider, also pin the namespace: 'hashicorp/aws' instead of '*/aws'.","If you want broad coverage, wildcard the type too: 'host/*/*' or '*/*'.","Prefer listing each concrete 'namespace/type' pair over trying to wildcard just the namespace."],"exampleFix":"// before\ninclude = [\"*/aws\"]\n\n// after\ninclude = [\"hashicorp/aws\"]\n// or, to match everything on the default host:\n// include = [\"*/*\"]","handlingStrategy":"validation","validationCode":"func validNamespaceWildcard(ns, typ string) error {\n    if ns == \"*\" && typ != \"*\" {\n        return fmt.Errorf(\"namespace wildcard requires the type to also be '*'\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never wildcard just the namespace; wildcard the type too, or pin the namespace.","Prefer listing concrete 'namespace/type' pairs over broad wildcarding.","Encode the wildcard-hierarchy rule in pattern-authoring UIs."],"tags":["provider-config","pattern","wildcard","namespace","validation","multi-source"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}