kubernetes/kops · error

unhandled kind %q in %s

Error message

unhandled kind %q in %s

What it means

RunDelete iterates over the resource kinds returned for the delete target and dispatches each to a kind-specific delete function (e.g. RunDeleteSSHPublicKey). When the group/version/kind of an object does not match any handled case, the default branch is hit and this error is returned, naming the unhandled GVK and the resource string. It means kOps does not know how to delete that object type via this command.

Source

Thrown at cmd/kops/delete.go:145

					continue
				}

				err := RunDeleteInstanceGroup(ctx, factory, out, options)
				if err != nil {
					return err
				}
			case *kopsapi.SSHCredential:
				options := &DeleteSSHPublicKeyOptions{
					ClusterName: v.ObjectMeta.Labels[kopsapi.LabelClusterName],
				}

				err = RunDeleteSSHPublicKey(ctx, factory, out, options)
				if err != nil {
					return err
				}
			default:
				klog.V(2).Infof("Type of object was %T", v)
				return fmt.Errorf("unhandled kind %q in %s", gvk, f)
			}
		}
	}

	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check `kops delete --help` for the list of supported kinds and use the exact supported kind name.
  2. Upgrade kops to a version that supports the resource kind you are deleting.
  3. Inspect the type with `klog.V(2)` output (run with -v=2) to confirm what object was encountered and delete it by another means (e.g. directly from the state store).

Example fix

// before
kops delete myresource --name cluster.example.com
// after
kops delete instancegroup mygroup --name cluster.example.com  # use a supported kind
Defensive patterns

Strategy: validation

Validate before calling

supported := []string{"cluster", "instancegroup", "secret", "sshpublickey"}
kind := strings.ToLower(strings.TrimSpace(target))
if !slices.Contains(supported, kind) {
    return fmt.Errorf("kind %q is not supported by kops delete; supported: %v", kind, supported)
}

Prevention

When it happens

Trigger: Running `kops delete` with an object kind the switch statement does not cover, e.g. a newer/unknown resource kind in the state store or a typo'd kind argument such as `kops delete secret` vs supported kinds (cluster, instancegroup, sshpublickey).

Common situations: Users upgrading kOps with state store entries of kinds added after their CLI version; passing an invalid kind argument to `kops delete`; plugins or custom resources appearing in the registry.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/1b5abfaba81c05cd. Report an issue: GitHub.