hashicorp/terraform · error

registry response to request for

Error message

registry response to request for %s archive has incorrect target %s

What it means

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).

Solutions

  1. Report the platform mismatch to the registry operator
  2. If mirroring, ensure metadata is keyed by (version, os, arch) and not just version
  3. Verify the requested Platform matches what the registry actually publishes for this version
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the metadata target before trusting the response.
if body.OS != target.OS || body.Arch != target.Arch {
    return fmt.Errorf("registry returned %s/%s for %s/%s — possible mirror corruption",
        body.OS, body.Arch, target.OS, target.Arch)
}

Type guard

func MatchesTarget(bodyOS, bodyArch, wantOS, wantArch string) bool {
    return bodyOS == wantOS && bodyArch == wantArch
}

Try / catch

meta, err := c.PackageMeta(ctx, provider, version, target)
if err != nil && strings.Contains(err.Error(), "incorrect target") {
    return fmt.Errorf("registry served wrong platform for %s %s: %w", provider, version, err)
}

Prevention

When it happens

Trigger: body.OS != target.OS || body.Arch != target.Arch for the archive metadata returned by the registry.

Common situations: 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.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/3510dfdef2b03b34. Report an issue: GitHub.

Appendix: source

Thrown at internal/getproviders/registry_client.go:280

		for _, version := range protoVersions {
			if supportedProtos.Has(version) {
				match = true
			}
		}
		if !match {
			// If the protocol version is not supported, try to find the closest
			// matching version.
			closest, err := c.findClosestProtocolCompatibleVersion(ctx, provider, version)
			if err != nil {
				return PackageMeta{}, err
			}
			protoErr.Suggestion = closest
			return PackageMeta{}, protoErr
		}
	}

	if body.OS != target.OS || body.Arch != target.Arch {
		return PackageMeta{}, fmt.Errorf("registry response to request for %s archive has incorrect target %s", target, Platform{body.OS, body.Arch})
	}

	downloadURL, err := url.Parse(body.DownloadURL)
	if err != nil {
		return PackageMeta{}, fmt.Errorf("registry response includes invalid download URL: %s", err)
	}
	downloadURL = resp.Request.URL.ResolveReference(downloadURL)
	if downloadURL.Scheme != "http" && downloadURL.Scheme != "https" {
		return PackageMeta{}, fmt.Errorf("registry response includes invalid download URL: must use http or https scheme")
	}

	ret := PackageMeta{
		Provider:         provider,
		Version:          version,
		ProtocolVersions: protoVersions,
		TargetPlatform: Platform{
			OS:   body.OS,
			Arch: body.Arch,

View on GitHub (pinned to d32a084675)