{"record":{"id":"ecc987cd285717ff","repo":"kubernetes/kops","slug":"cluster-is-required-ecc987","errorCode":null,"errorMessage":"cluster is required","messagePattern":"cluster is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/toolbox_enroll.go","lineNumber":93,"sourceCode":"\tBuildHost bool\n\n\t// PodCIDRs is the list of IP Address ranges to use for pods that run on this node\n\tPodCIDRs []string\n\n\tkubeconfig.CreateKubecfgOptions\n}\n\nfunc (o *ToolboxEnrollOptions) InitDefaults() {\n\to.SSHUser = \"root\"\n\to.SSHPort = 22\n}\n\nfunc RunToolboxEnroll(ctx context.Context, f commandutils.Factory, out io.Writer, options *ToolboxEnrollOptions) error {\n\tif !featureflag.Metal.Enabled() {\n\t\treturn fmt.Errorf(\"bare-metal support requires the Metal feature flag to be enabled\")\n\t}\n\tif options.ClusterName == \"\" {\n\t\treturn fmt.Errorf(\"cluster is required\")\n\t}\n\tif options.InstanceGroup == \"\" {\n\t\treturn fmt.Errorf(\"instance-group is required\")\n\t}\n\tif options.Host == \"\" {\n\t\t// Technically we could build the host resource without the PKI, but this isn't the case we are targeting right now.\n\t\treturn fmt.Errorf(\"host is required\")\n\t}\n\n\t// Resolve KOPS_BASE_URL early so that kops.Version is overridden\n\t// before the version downgrade check in ApplyClusterCmd.Run.\n\tif _, err := wellknownassets.BaseURL(); err != nil {\n\t\treturn err\n\t}\n\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn err","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/commands/toolbox_enroll.go#L75-L111","documentation":"RunToolboxEnroll requires the target cluster name to resolve state-store configuration and PKI. When `options.ClusterName` is empty, it fails immediately with this validation error before contacting any infrastructure.","triggerScenarios":"Invoking `kops toolbox enroll` without `--cluster` (or `--name`) and with no `KOPS_CLUSTER_NAME` set in the environment.","commonSituations":"Scripted enroll calls missing the flag; relying on `--cluster` short-hand that isn't supported; KOPS_CLUSTER_NAME unset in CI or new shell.","solutions":["Pass `--cluster <cluster-name>` explicitly on the command line","Set `export KOPS_CLUSTER_NAME=<cluster-name>` for the shell/CI job","Verify with `kops get clusters` that the name you pass matches an existing cluster in the state store"],"exampleFix":"// before\nkops toolbox enroll --instance-group metal --host 10.0.0.5\n// after\nkops toolbox enroll --cluster c.example.com --instance-group metal --host 10.0.0.5","handlingStrategy":"validation","validationCode":"CLUSTER=\"${KOPS_CLUSTER_NAME:-}\"\n[ -n \"$CLUSTER\" ] || { echo \"cluster is required: pass --cluster or set KOPS_CLUSTER_NAME\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --cluster explicitly in scripts","Export KOPS_CLUSTER_NAME in shared tooling","Validate required args in wrapper scripts before calling kops"],"tags":["cli","validation","missing-argument"],"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"}