{"record":{"id":"5854ec3746210d52","repo":"kubernetes/kops","slug":"name-is-required","errorCode":null,"errorMessage":"--name is required","messagePattern":"--name is required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_cluster.go","lineNumber":561,"sourceCode":"\t}\n\n\t// TODO: Reuse rootCommand stateStore logic?\n\n\tif c.OutDir == \"\" {\n\t\tif c.Target == cloudup.TargetTerraform {\n\t\t\tc.OutDir = \"out/terraform\"\n\t\t} else {\n\t\t\tc.OutDir = \"out\"\n\t\t}\n\t}\n\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif c.ClusterName == \"\" {\n\t\treturn fmt.Errorf(\"--name is required\")\n\t}\n\n\t{\n\t\tcluster, err := clientset.GetCluster(ctx, c.ClusterName)\n\t\tif err != nil {\n\t\t\tif apierrors.IsNotFound(err) {\n\t\t\t\tcluster = nil\n\t\t\t} else {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tif cluster != nil {\n\t\t\treturn fmt.Errorf(\"cluster %q already exists; use 'kops update cluster' to apply changes\", c.ClusterName)\n\t\t}\n\t}\n\n\tif c.OpenstackNetworkID != \"\" {","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_cluster.go#L543-L579","documentation":"RunCreateCluster requires an explicit cluster name; if options.ClusterName is empty the command fails with '--name is required'. The name is normally inferred from the positional argument or --name flag, but must be resolvable before checking the state store.","triggerScenarios":"Calling `kops create cluster` with no cluster-name positional argument and no --name flag, or invoking RunCreateCluster programmatically with an options struct lacking ClusterName.","commonSituations":"Scripting where the name variable was empty; running the command without arguments expecting an interactive prompt; KOPS_CLUSTER_NAME env var unset.","solutions":["Pass the cluster name as a positional argument: kops create cluster name.example.com","Or set --name name.example.com","Export KOPS_CLUSTER_NAME if relying on the environment","Ensure the wrapper script actually passes the name variable"],"exampleFix":"// before\nkops create cluster --zones us-east-1a\n// after\nkops create cluster mycluster.example.com --zones us-east-1a","handlingStrategy":"validation","validationCode":"clusterName := argsOrFlag\nif clusterName == \"\" {\n\tclusterName = os.Getenv(\"KOPS_CLUSTER_NAME\")\n}\nif clusterName == \"\" {\n\treturn fmt.Errorf(\"cluster name required: pass positional arg or --name\")\n}\nif !strings.HasSuffix(clusterName, \".\") && !isValidDNSName(clusterName) {\n\treturn fmt.Errorf(\"cluster name should be a valid DNS name\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the cluster name positionally in scripts","Set KOPS_CLUSTER_NAME in shared environments","Validate the name is a proper DNS name before calling kops"],"tags":["cli","validation","arguments"],"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-12T12:17:11.808Z"}