hashicorp/terraform · error

resource identity schema not found for type %q

Error message

resource identity schema not found for type %q

What it means

Returned by UpgradeResourceIdentity (internal/grpcwrap/provider6.go:821) when req.TypeName is not present in p.identitySchemas.IdentityTypes (a map populated once from p.GetResourceIdentitySchemas() at provider6 construction). The handler needs the identity schema's ImpliedType to encode the upgraded identity, so a missing entry is fatal and returns (nil, error).

Source

Thrown at internal/grpcwrap/provider6.go:821

func (p *provider6) GetResourceIdentitySchemas(_ context.Context, req *tfplugin6.GetResourceIdentitySchemas_Request) (*tfplugin6.GetResourceIdentitySchemas_Response, error) {
	resp := &tfplugin6.GetResourceIdentitySchemas_Response{
		IdentitySchemas: map[string]*tfplugin6.ResourceIdentitySchema{},
		Diagnostics:     []*tfplugin6.Diagnostic{},
	}

	for name, schema := range p.identitySchemas.IdentityTypes {
		resp.IdentitySchemas[name] = convert.ResourceIdentitySchemaToProto(schema)
	}

	resp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, p.identitySchemas.Diagnostics)
	return resp, nil
}

func (p *provider6) UpgradeResourceIdentity(_ context.Context, req *tfplugin6.UpgradeResourceIdentity_Request) (*tfplugin6.UpgradeResourceIdentity_Response, error) {
	resp := &tfplugin6.UpgradeResourceIdentity_Response{}
	resource, ok := p.identitySchemas.IdentityTypes[req.TypeName]
	if !ok {
		return nil, fmt.Errorf("resource identity schema not found for type %q", req.TypeName)
	}
	ty := resource.Body.ImpliedType()

	upgradeResp := p.provider.UpgradeResourceIdentity(providers.UpgradeResourceIdentityRequest{
		TypeName:        req.TypeName,
		Version:         req.Version,
		RawIdentityJSON: req.RawIdentity.Json,
	})
	resp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, upgradeResp.Diagnostics)

	if upgradeResp.Diagnostics.HasErrors() {
		return resp, nil
	}

	dv, err := encodeDynamicValue6(upgradeResp.UpgradedIdentity, ty)
	if err != nil {
		resp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, err)
		return resp, nil

View on GitHub (pinned to c9def3e214)

Solutions

  1. Upgrade the provider so its GetResourceIdentitySchemas declares the requested type.
  2. Verify the type name in the request matches exactly (case-sensitive) the provider's registered identity type names.
  3. Re-run terraform init to install a provider version consistent with the state's identity schema versions.
  4. If migrating, use moved blocks / remove state for the unregistered type rather than forcing identity upgrade.

Example fix

// before
// provider's GetResourceIdentitySchemas omits "aws_instance"
// core sends UpgradeResourceIdentity{TypeName:"aws_instance"}
// -> resource identity schema not found for type "aws_instance"

// after
// in the provider, register:
resp.IdentityTypes["aws_instance"] = &ResourceIdentitySchema{Version:1, Body:...}
Defensive patterns

Strategy: validation

Validate before calling

// Before requesting UpgradeResourceIdentity, confirm registration:
func identityTypeRegistered(s providers.GetResourceIdentitySchemasResponse, typ string) bool {
    _, ok := s.IdentityTypes[typ]
    return ok
}

Type guard

func knownIdentityTypes(s providers.GetResourceIdentitySchemasResponse) []string {
    out := make([]string, 0, len(s.IdentityTypes))
    for k := range s.IdentityTypes { out = append(out, k) }
    return out
}

Try / catch

if _, err := server.UpgradeResourceIdentity(ctx, req); err != nil {
    if strings.Contains(err.Error(), "resource identity schema not found") {
        // skip identity upgrade for this type / upgrade provider
    }
}

Prevention

When it happens

Trigger: Terraform core requests an UpgradeResourceIdentity RPC for a resource type the provider never registered in its GetResourceIdentitySchemas response; the map lookup p.identitySchemas.IdentityTypes[req.TypeName] returns ok==false.

Common situations: Provider version mismatch where the running provider binary lacks an identity schema for a type present in older state; a typo'd/case-mismatched type name in the request; state written by a newer provider read by an older core; provider forgetting to register identity schemas for types that have identities in state.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/a27451cacdd33f71. Report an issue: GitHub.