hashicorp/terraform · error
invalid provider type %q in provider matching pattern %q: mu
Error message
invalid provider type %q in provider matching pattern %q: must either be the wildcard * or a provider type name
What it means
The provider type (the last segment) is normalized via normalizeProviderNameOrWildcard: it must be exactly "*" or pass addrs.ParseProviderPart (lowercase alphanumerics and hyphens, non-empty). Anything else yields this error, quoting the bad type and the full pattern.
Source
Thrown at internal/getproviders/multi_source.go:174
givenHost := parts[0]
if givenHost == "*" {
host = svchost.Hostname(Wildcard)
} else {
normalHost, err := svchost.ForComparison(givenHost)
if err != nil {
return nil, fmt.Errorf("invalid hostname in provider matching pattern %q: %s", str, err)
}
// The remaining code below deals only with the namespace/type portions.
host = normalHost
}
parts = parts[1:]
}
pType, err := normalizeProviderNameOrWildcard(parts[1])
if err != nil {
return 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)
}
namespace, err := normalizeProviderNamespaceOrWildcard(parts[0])
if err != nil {
return nil, fmt.Errorf("invalid registry namespace %q in provider matching pattern %q: must either be the wildcard * or a literal namespace", parts[1], str)
}
ret[i] = addrs.Provider{
Hostname: host,
Namespace: namespace,
Type: pType,
}
if ret[i].Hostname == svchost.Hostname(Wildcard) && !(ret[i].Namespace == Wildcard && ret[i].Type == Wildcard) {
return nil, fmt.Errorf("invalid provider matching pattern %q: hostname can be a wildcard only if both namespace and provider type are also wildcards", str)
}
if ret[i].Namespace == Wildcard && ret[i].Type != Wildcard {
return nil, fmt.Errorf("invalid provider matching pattern %q: namespace can be a wildcard only if the provider type is also a wildcard", str)
}View on GitHub (pinned to c9def3e214)
Solutions
- Lowercase the provider type and use only letters, digits, and hyphens.
- Use "*" to wildcard the type (then namespace must also be "*").
- Remove any trailing slash that creates an empty final segment.
Example fix
# before include = ["hashicorp/AWS"] # after include = ["hashicorp/aws"]
Defensive patterns
Strategy: validation
Validate before calling
// Validate the provider type segment before parsing.
if t := parts[len(parts)-1]; t != "*" {
if err := validateProviderPart(t); err != nil {
return fmt.Errorf("provider type %q invalid: %w", t, err)
}
} Prevention
- Lowercase provider types; use only letters, digits, hyphens.
- Use "*" to wildcard the type (and namespace).
- Strip trailing slashes to avoid empty type segments.
When it happens
Trigger: Pattern's final segment is invalid: uppercase letters ("hashicorp/AWS"), contains dots/underscores, is empty (trailing slash), or has characters ParseProviderPart rejects.
Common situations: Uppercase provider names pasted from marketing docs; provider name with disallowed punctuation; trailing slash producing an empty type segment.
Related errors
- invalid provider matching pattern %q: must have either two o
- invalid hostname in provider matching pattern %q: %s
- invalid registry namespace %q in provider matching pattern %
- invalid provider matching pattern %q: hostname can be a wild
- invalid provider matching pattern %q: namespace can be a wil
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/ebee7a8b70e48768.
Report an issue: GitHub.