{"record":{"id":"b9b59f4ac8bbc598","repo":"hashicorp/terraform","slug":"invalid-hostname-in-provider-matching-pattern-q","errorCode":null,"errorMessage":"invalid hostname in provider matching pattern %q: %s","messagePattern":"invalid hostname in provider matching pattern %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getproviders/multi_source.go","lineNumber":162,"sourceCode":"\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:]\n\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","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/getproviders/multi_source.go#L144-L180","documentation":"When a pattern has three segments, the first is the hostname. If it is not the wildcard \"*\" it is normalized with svchost.ForComparison; an IDNA validation failure yields this error, appending the normalization error. The hostname must be a valid service host or the wildcard.","triggerScenarios":"A three-segment pattern whose first segment is an invalid hostname: contains underscores, invalid punycode, or other characters IDNA rejects. e.g. \"tf_mirror.local/hashicorp/aws\".","commonSituations":"Underscore in the hostname (common in internal DNS names but forbidden by IDNA); punycode that doesn't round-trip; stray punctuation.","solutions":["Use hyphens instead of underscores in hostnames.","Drop the hostname segment to use the default registry (\"hashicorp/aws\").","Use \"*\" only if you also wildcard namespace and type (\"*/*/*\")."],"exampleFix":"# before\ninclude = [\"tf_mirror.local/hashicorp/aws\"]\n\n# after\ninclude = [\"tf-mirror.local/hashicorp/aws\"]","handlingStrategy":"validation","validationCode":"// Validate the hostname segment up front.\nif len(parts) == 3 && parts[0] != \"*\" {\n    if _, err := svchost.ForComparison(parts[0]); err != nil {\n        return fmt.Errorf(\"hostname %q invalid: %w\", parts[0], err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use hyphens in hostnames, never underscores.","Omit the host segment to use the default registry.","Validate hostnames with svchost before persisting config."],"tags":["config","validation","hostname","pattern"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}