{"record":{"id":"3510dfdef2b03b34","repo":"hashicorp/terraform","slug":"registry-response-to-request-for-s-archive-has-in","errorCode":null,"errorMessage":"registry response to request for %s archive has incorrect target %s","messagePattern":"registry response to request for (.+?) archive has incorrect target (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getproviders/registry_client.go","lineNumber":280,"sourceCode":"\t\tfor _, version := range protoVersions {\n\t\t\tif supportedProtos.Has(version) {\n\t\t\t\tmatch = true\n\t\t\t}\n\t\t}\n\t\tif !match {\n\t\t\t// If the protocol version is not supported, try to find the closest\n\t\t\t// matching version.\n\t\t\tclosest, err := c.findClosestProtocolCompatibleVersion(ctx, provider, version)\n\t\t\tif err != nil {\n\t\t\t\treturn PackageMeta{}, err\n\t\t\t}\n\t\t\tprotoErr.Suggestion = closest\n\t\t\treturn PackageMeta{}, protoErr\n\t\t}\n\t}\n\n\tif body.OS != target.OS || body.Arch != target.Arch {\n\t\treturn PackageMeta{}, fmt.Errorf(\"registry response to request for %s archive has incorrect target %s\", target, Platform{body.OS, body.Arch})\n\t}\n\n\tdownloadURL, err := url.Parse(body.DownloadURL)\n\tif err != nil {\n\t\treturn PackageMeta{}, fmt.Errorf(\"registry response includes invalid download URL: %s\", err)\n\t}\n\tdownloadURL = resp.Request.URL.ResolveReference(downloadURL)\n\tif downloadURL.Scheme != \"http\" && downloadURL.Scheme != \"https\" {\n\t\treturn PackageMeta{}, fmt.Errorf(\"registry response includes invalid download URL: must use http or https scheme\")\n\t}\n\n\tret := PackageMeta{\n\t\tProvider:         provider,\n\t\tVersion:          version,\n\t\tProtocolVersions: protoVersions,\n\t\tTargetPlatform: Platform{\n\t\t\tOS:   body.OS,\n\t\t\tArch: body.Arch,","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/getproviders/registry_client.go#L262-L298","documentation":"PackageMeta requested an archive for a specific Platform (target.OS/target.Arch) but the registry's response body reported a different OS/Arch. This sanity check prevents silently installing a binary built for the wrong platform, so the mismatch is rejected with a plain fmt.Errorf.","triggerScenarios":"Registry download endpoint echoes back OS/Arch that do not match the path the installer requested (e.g. asked for linux/amd64, got darwin/arm64). Typically a registry routing bug, a mirror returning a cached package for the wrong target, or a hand-built registry ignoring the platform path segment.","commonSituations":"Custom registry ignores platform path and always returns amd64; CDN cache key omits platform; registry upgraded its API and the os/arch field names drifted; requesting an arch the registry maps differently (e.g. \"x86_64\" vs \"amd64\").","solutions":["Verify the requested platform string (GOOS/GOARCH) is one the registry actually serves.","Check the registry backend routes the OS/Arch path segments correctly to the matching archive.","Clear any CDN/mirror cache keyed without the platform dimension.","Confirm the registry returns os/arch in the exact vocabulary Terraform sends (e.g. \"amd64\" not \"x86_64\")."],"exampleFix":"// before: request linux/amd64, registry returns\n{\"os\":\"darwin\",\"arch\":\"arm64\",...}\n// after: registry returns the requested target\n{\"os\":\"linux\",\"arch\":\"amd64\",...}","handlingStrategy":"validation","validationCode":"// Before calling PackageMeta, confirm the platform is one the registry serves\n// by listing versions+platforms and matching OS/Arch exactly.\nfunc platformServed(available map[string][]Platform, ver string, want Platform) bool {\n    for _, p := range available[ver] {\n        if p.OS == want.OS && p.Arch == want.Arch {\n            return true\n        }\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":"meta, err := client.PackageMeta(ctx, provider, ver, plat)\nif err != nil {\n    if strings.Contains(err.Error(), \"incorrect target\") {\n        // registry served a different platform; surface a clearer message to the user\n    }\n    return err\n}","preventionTips":["Request a platform the registry actually publishes (check the versions/platforms list first).","For custom registries, ensure the download endpoint honors the OS/Arch path segments.","Keep the registry's platform vocabulary aligned with Terraform's (GOOS/GOARCH)."],"tags":["terraform","registry","platform","os-arch","provider-install"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}