{"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":"exception","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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/getproviders/registry_client.go#L262-L298","documentation":"Thrown after decoding the registry response when the returned OS/Arch do not match the requested target platform. This guards against a registry serving an archive for the wrong platform (a consistency/invariant check, not wrapped by errQueryFailed).","triggerScenarios":"body.OS != target.OS || body.Arch != target.Arch for the archive metadata returned by the registry.","commonSituations":"Registry bug or cache serving the wrong platform's metadata; a mirror that indexes archives by version only and returns the first match; a custom registry that ignores the OS/arch query parameters.","solutions":["Report the platform mismatch to the registry operator","If mirroring, ensure metadata is keyed by (version, os, arch) and not just version","Verify the requested Platform matches what the registry actually publishes for this version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the metadata target before trusting the response.\nif body.OS != target.OS || body.Arch != target.Arch {\n    return fmt.Errorf(\"registry returned %s/%s for %s/%s — possible mirror corruption\",\n        body.OS, body.Arch, target.OS, target.Arch)\n}","typeGuard":"func MatchesTarget(bodyOS, bodyArch, wantOS, wantArch string) bool {\n    return bodyOS == wantOS && bodyArch == wantArch\n}","tryCatchPattern":"meta, err := c.PackageMeta(ctx, provider, version, target)\nif err != nil && strings.Contains(err.Error(), \"incorrect target\") {\n    return fmt.Errorf(\"registry served wrong platform for %s %s: %w\", provider, version, err)\n}","preventionTips":["Key mirror metadata by (version, os, arch), not version alone","Validate registry responses against the requested target before consuming them"],"tags":["registry","platform","provider","validation"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}