{"record":{"id":"d2ae3b45345169b3","repo":"hashicorp/terraform","slug":"failed-to-create-backend-alias-from-alias-q-the","errorCode":null,"errorMessage":"failed to create backend alias from alias %q. The hostname is not in the correct format. This is a bug in the backend","messagePattern":"failed to create backend alias from alias %q\\. The hostname is not in the correct format\\. This is a bug in the backend","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/backend/remote/backend.go","lineNumber":210,"sourceCode":"\n\t// Make sure that only one of workspace name or a prefix is configured.\n\tif name != \"\" && prefix != \"\" {\n\t\tdiags = diags.Append(tfdiags.AttributeValue(\n\t\t\ttfdiags.Error,\n\t\t\t\"Invalid workspaces configuration\",\n\t\t\t`Only one of workspace \"name\" or \"prefix\" is allowed.`,\n\t\t\tcty.Path{cty.GetAttrStep{Name: \"workspaces\"}},\n\t\t))\n\t}\n\n\treturn obj, diags\n}\n\nfunc (b *Remote) ServiceDiscoveryAliases() ([]backendrun.HostAlias, error) {\n\taliasHostname, err := svchost.ForComparison(genericHostname)\n\tif err != nil {\n\t\t// This should never happen because the hostname is statically defined.\n\t\treturn nil, fmt.Errorf(\"failed to create backend alias from alias %q. The hostname is not in the correct format. This is a bug in the backend\", genericHostname)\n\t}\n\n\ttargetHostname, err := svchost.ForComparison(b.hostname)\n\tif err != nil {\n\t\t// This should never happen because the 'to' alias is the backend host, which has likely\n\t\t// already been evaluated as a svchost.Hostname by now\n\t\treturn nil, fmt.Errorf(\"failed to create backend alias to target %q. The hostname is not in the correct format\", b.hostname)\n\t}\n\n\treturn []backendrun.HostAlias{\n\t\t{\n\t\t\tFrom: aliasHostname,\n\t\t\tTo:   targetHostname,\n\t\t},\n\t}, nil\n}\n\n// Configure implements backend.Backend.","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote/backend.go#L192-L228","documentation":"Returned by Remote.ServiceDiscoveryAliases when svchost.ForComparison(genericHostname) fails for the statically-defined generic hostname constant. The code comment explicitly states this should never happen — it is a defensive check against an invalid built-in constant, so encountering it indicates a bug in the Terraform build itself rather than user configuration.","triggerScenarios":"ServiceDiscoveryAliases() is invoked during backend host aliasing; svchost.ForComparison rejects the genericHostname constant because it is empty, too long, or otherwise RFC-compliance-violating. This requires the compiled-in constant to be malformed.","commonSituations":"A custom/forked Terraform build that changed genericHostname to an invalid value; an extremely old or corrupted binary; practically never seen in official releases.","solutions":["Report a bug — this path is unreachable with the official genericHostname constant.","If running a fork, verify the genericHostname constant is a valid RFC-1123 hostname (e.g. 'app.terraform.io').","Rebuild from a clean checkout of the official source.","Confirm the binary is not corrupted (checksums)."],"exampleFix":"// before: custom build set genericHostname = \"\"\n// after\nconst genericHostname = \"app.terraform.io\"","handlingStrategy":"validation","validationCode":"// Validate the built-in constant at startup (defensive, since it should be unreachable)\nfunc validateGenericHostname() error {\n  if _, err := svchost.ForComparison(genericHostname); err != nil {\n    return fmt.Errorf(\"build is corrupt: genericHostname %q invalid: %w\", genericHostname, err)\n  }\n  return nil\n}","typeGuard":null,"tryCatchPattern":"// This is a bug path; surface it loudly rather than recovering\nif _, err := b.ServiceDiscoveryAliases(); err != nil && strings.Contains(err.Error(), \"bug in the backend\") {\n    panic(fmt.Errorf(\"unreachable: %w\", err)) // file an issue\n}","preventionTips":["Run official, checksum-verified Terraform binaries.","In forks, validate genericHostname against RFC-1123 before building.","Add a unit test asserting svchost.ForComparison(genericHostname) succeeds.","Treat this error as a release-blocker bug report."],"tags":["terraform-remote-backend","host-validation","bug","service-discovery"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}