{"record":{"id":"cbb4be9884610c89","repo":"hashicorp/terraform","slug":"invalid-provider-matching-pattern-q-hostname-can","errorCode":null,"errorMessage":"invalid provider matching pattern %q: hostname can be a wildcard only if both namespace and provider type are also wildcards","messagePattern":"invalid provider matching pattern %q: hostname can be a wildcard only if both namespace and provider type are also wildcards","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getproviders/multi_source.go","lineNumber":188,"sourceCode":"\t\t}\n\n\t\tpType, err := normalizeProviderNameOrWildcard(parts[1])\n\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","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/getproviders/multi_source.go#L170-L206","documentation":"A wildcard hostname (\"*\" in the first segment) is only legal when both namespace and type are also wildcards — i.e. the only valid all-host form is \"*/*/*\". A pattern like \"*/hashicorp/aws\" is rejected because narrowing by host while wildcarding host alone is ambiguous.","triggerScenarios":"Writing a three-segment pattern starting with \"*\" but with a concrete namespace and/or type, e.g. \"*/hashicorp/aws\" or \"*/*/aws\". The validator rejects the combination.","commonSituations":"Trying to say \"any host, this namespace/type\" in a mirror include rule; misunderstanding that host wildcard forces full wildcard.","solutions":["If you want all hosts, use \"*/*/*\" (matches everything).","Otherwise specify the concrete hostname: \"registry.terraform.io/hashicorp/aws\".","Drop the host segment entirely to default to the registry: \"hashicorp/aws\"."],"exampleFix":"# before\ninclude = [\"*/hashicorp/aws\"]\n\n# after\ninclude = [\"registry.terraform.io/hashicorp/aws\"]\n# or, to truly match all: [\"*/*/*\"]","handlingStrategy":"validation","validationCode":"// Enforce: host wildcard implies namespace and type wildcards.\nif len(parts) == 3 && parts[0] == \"*\" && !(parts[1] == \"*\" && parts[2] == \"*\") {\n    return fmt.Errorf(\"hostname wildcard requires */*/*\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use \"*/*/*\" to match all hosts, never \"*/ns/type\".","Specify a concrete hostname when narrowing by namespace/type.","Drop the host segment to default to the registry."],"tags":["config","validation","pattern","wildcard"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}