{"record":{"id":"09302e8efb5b4dc3","repo":"kubernetes/kops","slug":"one-or-more-key-value-pairs-are-malformed-s-w","errorCode":null,"errorMessage":"one or more key=value pairs are malformed:\n%s\n:%w","messagePattern":"one or more key=value pairs are malformed:\n(.+?)\n:%w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_cluster.go","lineNumber":956,"sourceCode":"}\n\n// parseCloudLabels takes a CSV list of key=value records and parses them into a map. Nested '='s are supported via\n// quoted strings (eg `foo=\"bar=baz\"` parses to map[string]string{\"foo\":\"bar=baz\"}. Nested commas are not supported.\nfunc parseCloudLabels(s string) (map[string]string, error) {\n\t// Replace commas with newlines to allow a single pass with csv.Reader.\n\t// We can't use csv.Reader for the initial split because it would see each key=value record as a single field\n\t// and significantly complicates using quoted fields as keys or values.\n\trecords := strings.ReplaceAll(s, \",\", \"\\n\")\n\n\t// Let the CSV library do the heavy-lifting in handling nested ='s\n\tr := csv.NewReader(strings.NewReader(records))\n\tr.Comma = '='\n\tr.FieldsPerRecord = 2\n\tr.LazyQuotes = false\n\tr.TrimLeadingSpace = true\n\tkvPairs, err := r.ReadAll()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"one or more key=value pairs are malformed:\\n%s\\n:%w\", records, err)\n\t}\n\n\tm := make(map[string]string, len(kvPairs))\n\tfor _, pair := range kvPairs {\n\t\tm[pair[0]] = pair[1]\n\t}\n\treturn m, nil\n}\n\nfunc loadSSHPublicKeys(sshPublicKey string) (map[string][]byte, error) {\n\tsshPublicKeys := make(map[string][]byte)\n\tif sshPublicKey != \"\" {\n\t\tsshPublicKey = utils.ExpandPath(sshPublicKey)\n\t\tauthorized, err := os.ReadFile(sshPublicKey)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tsshPublicKeys[fi.SecretNameSSHPrimary] = authorized","sourceCodeStart":938,"sourceCodeEnd":974,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_cluster.go#L938-L974","documentation":"parseCloudLabels splits a CSV of key=value records (with newline substitution for CSV parsing); this aggregates all records that the CSV reader could not parse, listing them in the error. It is a pure input-validation failure on the --cloud-labels value.","triggerScenarios":"Thrown at cmd/kops/create_cluster.go:956 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the malformed key=value records shown in the error message","Quote values containing '=' e.g. foo=\"bar=baz\"","Ensure records are comma-separated without stray quotes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}