hashicorp/terraform · error

resource identity schema not found for type

Error message

resource identity schema not found for type %q

What it means

Returned in UpgradeResourceIdentity when the requested resource type name is not present in p.schema.ResourceTypes. Distinct from the 'identity schema not found' family: here the entire resource type is unknown, so the wrapper cannot even reach resource.Identity.ImpliedType(). Returns nil response with a gRPC error. Uses %q (quoted) formatting, unlike the %s used by the identity-not-found errors. '%q' is the requested type name.

Solutions

  1. Run 'terraform providers schema' to list the resource types the active provider registers; the requested type must appear there.
  2. If the type was renamed, use 'removed' block or 'moved' block to migrate state, or manually edit state to the new type name.
  3. Upgrade or downgrade the provider to match the state's resource type names.
  4. Confirm the provider in .terraform.lock.hcl is the build expected to register the type.
  5. If authoring a provider, ensure GetProviderSchema registers every resource type that may appear in state.

Example fix

// before: state references 'example_old_thing' but provider only registers 'example_thing'
// after: rename in state
$ terraform state replace-provider example.com/example/example_old_thing example.com/example/example_thing
// or update provider to register the legacy alias type
Defensive patterns

Strategy: type-guard

Validate before calling

// Caller-side: verify resource type exists before requesting identity upgrade.
if _, ok := schemas.ResourceTypes[req.TypeName]; !ok {
    return fmt.Errorf("type %q not registered; cannot upgrade identity", req.TypeName)
}

Type guard

func typeRegistered(schemas *schemas.Schemas, t string) bool {
    _, ok := schemas.ResourceTypes[t]; return ok
}

Try / catch

// Caller-side: rename state to current type name then retry.
if err != nil && strings.Contains(err.Error(), "resource identity schema not found for type") {
    if mapped := legacyTypeMap[req.TypeName]; mapped != "" {
        req.TypeName = mapped
        return retry()
    }
}

Prevention

When it happens

Trigger: UpgradeResourceIdentityRequest arrives with a TypeName that is absent from the provider's declared ResourceTypes map. The provider has no schema for that type at all, so identity upgrade is impossible.

Common situations: State file references a resource type the current provider build no longer registers; typo in the request type name; provider namespace/name change left stale state; partial provider upgrade where the type was renamed or removed; test fixture requesting a non-existent type.

Related errors


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

Appendix: source

Thrown at internal/grpcwrap/provider.go:760

func (p *provider) GetResourceIdentitySchemas(_ context.Context, req *tfplugin5.GetResourceIdentitySchemas_Request) (*tfplugin5.GetResourceIdentitySchemas_Response, error) {
	resp := &tfplugin5.GetResourceIdentitySchemas_Response{
		IdentitySchemas: map[string]*tfplugin5.ResourceIdentitySchema{},
		Diagnostics:     []*tfplugin5.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 *provider) UpgradeResourceIdentity(_ context.Context, req *tfplugin5.UpgradeResourceIdentity_Request) (*tfplugin5.UpgradeResourceIdentity_Response, error) {
	resp := &tfplugin5.UpgradeResourceIdentity_Response{}
	resource, ok := p.schema.ResourceTypes[req.TypeName]
	if !ok {
		return nil, fmt.Errorf("resource identity schema not found for type %q", req.TypeName)
	}
	ty := resource.Identity.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 := encodeDynamicValue(upgradeResp.UpgradedIdentity, ty)
	if err != nil {
		resp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, err)
		return resp, nil
	}
	resp.UpgradedIdentity = &tfplugin5.ResourceIdentityData{

View on GitHub (pinned to d32a084675)