{"record":{"id":"ba776d5d3d0743dd","repo":"kubernetes/kops","slug":"unable-to-parse-yaml-v-v-ba776d","errorCode":null,"errorMessage":"unable to parse YAML %v: %v","messagePattern":"unable to parse YAML (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_secret_encryptionconfig.go","lineNumber":118,"sourceCode":"\t\treturn err\n\t}\n\tvar data []byte\n\tif options.EncryptionConfigPath == \"-\" {\n\t\tdata, err = ConsumeStdin()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"reading encryption config from stdin: %v\", err)\n\t\t}\n\t} else {\n\t\tdata, err = os.ReadFile(options.EncryptionConfigPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"reading encryption config %v: %v\", options.EncryptionConfigPath, err)\n\t\t}\n\t}\n\n\tvar parsedData map[string]interface{}\n\terr = kops.ParseRawYaml(data, &parsedData)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to parse YAML %v: %v\", options.EncryptionConfigPath, err)\n\t}\n\n\tsecret := &fi.Secret{\n\t\tData: data,\n\t}\n\n\tif !options.Force {\n\t\t_, created, err := secretStore.GetOrCreateSecret(ctx, \"encryptionconfig\", secret)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"adding encryptionconfig secret: %v\", err)\n\t\t}\n\t\tif !created {\n\t\t\treturn fmt.Errorf(\"failed to create the encryptionconfig secret as it already exists. Pass the `--force` flag to replace an existing secret\")\n\t\t}\n\t} else {\n\t\t_, err := secretStore.ReplaceSecret(\"encryptionconfig\", secret)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"updating encryptionconfig secret: %v\", err)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_secret_encryptionconfig.go#L100-L136","documentation":"Returned when `kops.ParseRawYaml` fails to unmarshal the encryption config file contents into a `map[string]interface{}`. kOps parses the YAML purely to validate that the file is well-formed YAML before storing its raw bytes as the encryptionconfig secret. A YAML syntax error (bad indentation, tabs, malformed keys) triggers this error.","triggerScenarios":"Running `kops create secret encryptionconfig` with a file whose contents are not valid YAML — e.g. tabs for indentation, unbalanced quotes/brackets, or accidentally passing a binary or JSON-syntax-error file.","commonSituations":"Hand-edited EncryptionConfiguration manifests introducing indentation errors; passing a kube-apiserver binary secret instead of YAML; Windows line-ending or encoding issues; copy-pasting YAML from docs losing indentation.","solutions":["Validate the file with a YAML linter (`yamllint <path>` or `python -c 'import yaml,sys; yaml.safe_load(open(sys.argv[1]))' <path>`) and fix the reported syntax error.","Replace tabs with spaces and confirm consistent 2-space indentation.","Confirm the file is a Kubernetes EncryptionConfiguration YAML document, not another artifact."],"exampleFix":"// before (tabs cause parse failure)\nresources:\n\t- providers:\n// after (spaces only)\nresources:\n  - providers:","handlingStrategy":"validation","validationCode":"const yaml = require('js-yaml');\ntry { yaml.load(fs.readFileSync(path, 'utf8')); }\ncatch (e) { throw new Error(`Invalid YAML in ${path}: ${e.message}`); }","typeGuard":"function isValidYaml(text) {\n  try { require('js-yaml').load(text); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  runKops(['create','secret','encryptionconfig', cluster, path]);\n} catch (e) {\n  if (/unable to parse YAML/.test(e.message)) {\n    console.error('Fix YAML syntax in ' + path + ' (indentation, tabs, quotes).');\n  }\n  throw e;\n}","preventionTips":["Run yamllint on manifests before applying","Use spaces, never tabs, in YAML","Validate EncryptionConfiguration against the k8s API docs"],"tags":["cli","yaml","validation","kops"],"backgroundTag":"yaml-parse-error","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"}