{"record":{"id":"aa69ef7055943599","repo":"kubernetes/kops","slug":"name-is-required-aa69ef","errorCode":null,"errorMessage":"--name is required","messagePattern":"--name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete_instance.go","lineNumber":124,"sourceCode":"\t\t# Delete an instance from the currently active cluster without\n\t\tvalidation or draining.\n\t\tkops delete instance --cloudonly i-0a5ed581b862d3425 --yes\n\t\t`))\n\n\tdeleteInstanceShort := i18n.T(`Delete an instance.`)\n\n\tvar options DeleteInstanceOptions\n\toptions.initDefaults()\n\n\tcmd := &cobra.Command{\n\t\tUse:     \"instance INSTANCE|NODE\",\n\t\tShort:   deleteInstanceShort,\n\t\tLong:    deleteInstanceLong,\n\t\tExample: deleteInstanceExample,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\toptions.ClusterName = rootCommand.ClusterName(true)\n\t\t\tif options.ClusterName == \"\" {\n\t\t\t\treturn fmt.Errorf(\"--name is required\")\n\t\t\t}\n\n\t\t\tif len(args) == 0 {\n\t\t\t\treturn fmt.Errorf(\"must specify ID of instance or name of node to delete\")\n\t\t\t}\n\t\t\toptions.InstanceID = args[0]\n\n\t\t\tif len(args) != 1 {\n\t\t\t\treturn fmt.Errorf(\"can only delete one instance at a time\")\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t\tValidArgsFunction: completeInstanceOrNode(f, &options),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn RunDeleteInstance(cmd.Context(), f, out, &options)\n\t\t},\n\t}","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete_instance.go#L106-L142","documentation":"The `kops delete instance` command's Args validator sets options.ClusterName from the root command's cluster name resolution; if it is empty the command is rejected with this error before any deletion attempt.","triggerScenarios":"Running `kops delete instance <id>` without --name, KOPS_CLUSTER_NAME, or a kops-configured default cluster so rootCommand.ClusterName(true) returns \"\".","commonSituations":"Scripted deletions in CI without env vars; fresh machines without kops state store context; typos in the --name flag.","solutions":["Pass `--name <cluster.example.com>` to the command.","Export KOPS_CLUSTER_NAME=<cluster.example.com>.","Ensure KOPS_STATE_STORE is set so the cluster name can be resolved."],"exampleFix":"// before\nkops delete instance i-0abc123\n// after\nkops delete instance i-0abc123 --name cluster.example.com","handlingStrategy":"validation","validationCode":"if clusterName == \"\" {\n    return fmt.Errorf(\"--name or KOPS_CLUSTER_NAME must be set for kops delete instance\")\n}\nargs = append(args, \"--name\", clusterName)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass --name explicitly in all delete commands.","Set KOPS_STATE_STORE and KOPS_CLUSTER_NAME in CI environments.","Never rely on implicit cluster-name resolution for destructive ops."],"tags":["cli","validation","missing-flag"],"backgroundTag":"missing-required-flag","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}