hashicorp/terraform · error

Error parsing as a provider address

Error message

Error parsing %q as a provider address: %w

What it means

Thrown while building the reattach map when a JSON object key (the provider source string) cannot be parsed by addrs.ParseProviderSourceString. Provider keys must follow the [hostname/]namespace/name form.

Solutions

  1. Use the full three-part form 'registry.terraform.io/hashicorp/aws' or at minimum 'hashicorp/aws'
  2. Remove extra segments and illegal characters from the key
  3. Cross-check the key against the provider's published source address

Example fix

// before: {"aws": {...}}
// after : {"registry.terraform.io/hashicorp/aws": {...}}
Defensive patterns

Strategy: validation

Validate before calling

// Validate each provider key is a parseable provider address.
for k := range m {
    if _, diags := addrs.ParseProviderSourceString(k); diags.HasErrors() {
        return fmt.Errorf("reattach key %q is not a valid provider address", k)
    }
}

Type guard

func IsValidProviderSource(s string) bool {
    _, diags := addrs.ParseProviderSourceString(s)
    return !diags.HasErrors()
}

Try / catch

providers, err := reattach.DecodeProviders(raw)
if err != nil && strings.Contains(err.Error(), "provider address") {
    return fmt.Errorf("a reattach key must be '<hostname>/<ns>/<name>' or '<ns>/<name>': %w", err)
}

Prevention

When it happens

Trigger: addrs.ParseProviderSourceString(p).HasErrors() is true for the map key p (e.g. 'aws', 'hashicorp/aws/extra', or a string with illegal characters).

Common situations: Key written as a bare provider name without a namespace; extra path segments; typo such as 'hashcrop/aws'; slashes or characters illegal in a provider address.

Related errors


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

Appendix: source

Thrown at internal/getproviders/reattach/reattach.go:59

		type reattachConfig struct {
			Protocol        string
			ProtocolVersion int
			Addr            struct {
				Network string
				String  string
			}
			Pid  int
			Test bool
		}
		var m map[string]reattachConfig
		err := json.Unmarshal([]byte(in), &m)
		if err != nil {
			return unmanagedProviders, fmt.Errorf("Invalid format for %s: %w", TF_REATTACH_PROVIDERS, err)
		}
		for p, c := range m {
			a, diags := addrs.ParseProviderSourceString(p)
			if diags.HasErrors() {
				return unmanagedProviders, fmt.Errorf("Error parsing %q as a provider address: %w", a, diags.Err())
			}
			var addr net.Addr
			switch c.Addr.Network {
			case "unix":
				addr, err = net.ResolveUnixAddr("unix", c.Addr.String)
				if err != nil {
					return unmanagedProviders, fmt.Errorf("Invalid unix socket path %q for %q: %w", c.Addr.String, p, err)
				}
			case "tcp":
				addr, err = net.ResolveTCPAddr("tcp", c.Addr.String)
				if err != nil {
					return unmanagedProviders, fmt.Errorf("Invalid TCP address %q for %q: %w", c.Addr.String, p, err)
				}
			default:
				return unmanagedProviders, fmt.Errorf("Unknown address type %q for %q", c.Addr.Network, p)
			}
			unmanagedProviders[a] = &plugin.ReattachConfig{
				Protocol:        plugin.Protocol(c.Protocol),

View on GitHub (pinned to d32a084675)