{"record":{"id":"6cd820c06cf32764","repo":"kubernetes/kops","slug":"clustername-is-required","errorCode":null,"errorMessage":"clusterName is required","messagePattern":"clusterName is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/client/simple/vfsclientset/cluster.go","lineNumber":67,"sourceCode":"\nfunc (c *ClusterVFS) Get(ctx context.Context, name string, options metav1.GetOptions) (*api.Cluster, error) {\n\tif options.ResourceVersion != \"\" {\n\t\treturn nil, fmt.Errorf(\"ResourceVersion not supported in ClusterVFS::Get\")\n\t}\n\to, err := c.find(ctx, name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif o == nil {\n\t\treturn nil, errors.NewNotFound(schema.GroupResource{Group: api.GroupName, Resource: \"Cluster\"}, name)\n\t}\n\treturn o, nil\n}\n\n// Deprecated, but we need this for now..\nfunc (c *ClusterVFS) configBase(clusterName string) (vfs.Path, error) {\n\tif clusterName == \"\" {\n\t\treturn nil, fmt.Errorf(\"clusterName is required\")\n\t}\n\tconfigPath := c.basePath.Join(clusterName)\n\treturn configPath, nil\n}\n\nfunc (c *ClusterVFS) List(ctx context.Context, options metav1.ListOptions) (*api.ClusterList, error) {\n\tnames, err := c.listNames(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar items []api.Cluster\n\n\tfor _, clusterName := range names {\n\t\tcluster, err := c.find(ctx, clusterName)\n\t\tif err != nil {\n\t\t\tklog.Warningf(\"cluster %q found in state store listing, but cannot be loaded: %v\", clusterName, err)\n\t\t\tcontinue","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/client/simple/vfsclientset/cluster.go#L49-L85","documentation":"The deprecated ClusterVFS.configBase helper builds the VFS path to a cluster's config directory by joining the cluster name onto the store base path. An empty cluster name would produce an invalid base path, so the function rejects it upfront.","triggerScenarios":"Calling ClusterVFS.configBase(\"\") directly, or indirectly via find() when Get/List are invoked with an empty cluster name.","commonSituations":"Variables holding the cluster name that are empty due to failed flag parsing, unset config values, or uninitialized structs passed to Get/find.","solutions":["Ensure a non-empty cluster name is passed to Get/find/configBase","Validate the cluster name (e.g. from flags or config) before calling the store","If the name is derived from context or a Cluster object, check ObjectMeta.Name is populated"],"exampleFix":"// before\nbase, err := c.configBase(clusterName) // clusterName may be \"\"\n// after\nif clusterName == \"\" {\n\treturn nil, fmt.Errorf(\"cluster name must be provided\")\n}\nbase, err := c.configBase(clusterName)","handlingStrategy":"validation","validationCode":"func validateClusterName(name string) error {\n\tif strings.TrimSpace(name) == \"\" {\n\t\treturn fmt.Errorf(\"cluster name must be provided\")\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"base, err := c.configBase(clusterName)\nif err != nil {\n\treturn fmt.Errorf(\"cannot resolve config base for %q: %w\", clusterName, err)\n}","preventionTips":["Validate cluster names at flag/config parsing time","Never call deprecated helpers like configBase directly in new code","Assert ObjectMeta.Name is set on structs before store calls"],"tags":["go","vfs","validation"],"backgroundTag":"missing-required-argument","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"}