{"record":{"id":"d02c431c381d605c","repo":"kubernetes/kops","slug":"error-parsing-global-cloud-labels-v","errorCode":null,"errorMessage":"error parsing global cloud labels: %v","messagePattern":"error parsing global cloud labels: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_cluster.go","lineNumber":610,"sourceCode":"\t}\n\n\tcluster := clusterResult.Cluster\n\tinstanceGroups := clusterResult.InstanceGroups\n\n\tvar controlPlanes []*api.InstanceGroup\n\tvar nodes []*api.InstanceGroup\n\tfor _, ig := range instanceGroups {\n\t\tswitch {\n\t\tcase ig.Spec.Role.HasControlPlane():\n\t\t\tcontrolPlanes = append(controlPlanes, ig)\n\t\tcase ig.Spec.Role.HasNode():\n\t\t\tnodes = append(nodes, ig)\n\t\t}\n\t}\n\n\tcloudLabels, err := parseCloudLabels(c.CloudLabels)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing global cloud labels: %v\", err)\n\t}\n\tif len(cloudLabels) != 0 {\n\t\tcluster.Spec.CloudLabels = cloudLabels\n\t}\n\n\tif c.AssociatePublicIP != nil {\n\t\tfor _, group := range instanceGroups {\n\t\t\tgroup.Spec.AssociatePublicIP = c.AssociatePublicIP\n\t\t}\n\t}\n\n\tif c.ControlPlaneTenancy != \"\" {\n\t\tfor _, group := range controlPlanes {\n\t\t\tgroup.Spec.Tenancy = c.ControlPlaneTenancy\n\t\t}\n\t}\n\n\tif c.NodeTenancy != \"\" {","sourceCodeStart":592,"sourceCodeEnd":628,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_cluster.go#L592-L628","documentation":"Global cloud labels passed via --cloud-labels are parsed by parseCloudLabels; any parse failure is wrapped as 'error parsing global cloud labels'. The flag expects a comma-separated list of key=value pairs; malformed input fails here.","triggerScenarios":"Passing --cloud-labels with entries lacking '=', duplicate keys, or invalid characters, e.g. --cloud-labels \"foo,bar=baz\".","commonSituations":"Forgetting the = separator; quoting/escaping issues in shell that split pairs; building the flag from a template that emitted empty entries.","solutions":["Fix the flag format to key=value pairs separated by commas: --cloud-labels \"owner=team,env=prod\"","Quote the whole flag value in shell to avoid splitting","The wrapped %v error names the offending pair — correct that specific entry","Omit --cloud-labels if none are needed"],"exampleFix":"// before\n--cloud-labels \"owner team,env=prod\"\n// after\n--cloud-labels \"owner=team,env=prod\"","handlingStrategy":"validation","validationCode":"func validCloudLabels(s string) error {\n\tif s == \"\" { return nil }\n\tfor _, pair := range strings.Split(s, \",\") {\n\t\tif !strings.Contains(pair, \"=\") || strings.SplitN(pair, \"=\", 2)[0] == \"\" {\n\t\t\treturn fmt.Errorf(\"invalid cloud label %q: want key=value\", pair)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote --cloud-labels values in shell","Always use key=value comma-separated format","Test the flag with --dry-run first"],"tags":["cli","labels","parsing"],"backgroundTag":"invalid-flag-format","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"}