{"record":{"id":"188a57dbbd170d78","repo":"kubernetes/kops","slug":"unable-to-parse-yaml-v-v","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_ciliumpassword.go","lineNumber":120,"sourceCode":"\t}\n\n\tvar data []byte\n\tif options.CiliumPasswordFilePath == \"-\" {\n\t\tdata, err = ConsumeStdin()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"reading Cilium IPSec config from stdin: %v\", err)\n\t\t}\n\t} else {\n\t\tdata, err = os.ReadFile(options.CiliumPasswordFilePath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"reading Cilium IPSec config %v: %v\", options.CiliumPasswordFilePath, 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.CiliumPasswordFilePath, 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, \"ciliumpassword\", secret)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error adding Cilium IPSec secret: %v\", err)\n\t\t}\n\t\tif !created {\n\t\t\treturn fmt.Errorf(\"failed to create the Cilium IPSec 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(\"ciliumpassword\", secret)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"updating Cilium IPSec secret: %v\", err)","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_secret_ciliumpassword.go#L102-L138","documentation":"This error occurs when the Cilium IPsec config data read from the file or stdin is not valid YAML. kops.ParseRawYaml fails to decode the bytes into a map[string]interface{}, so the config cannot be validated and stored as the ciliumpassword secret.","triggerScenarios":"Running `kops create secret ciliumpassword -f <path>` (or via stdin) where the content has YAML syntax errors: bad indentation, tabs, unclosed quotes, or binary/non-UTF8 garbage.","commonSituations":"Hand-edited config with tab characters; copied YAML losing indentation; passing a binary IPsec key file instead of the YAML config; editor adding non-UTF8 characters.","solutions":["Validate the file: `yamllint <path>` or load it in a YAML parser to find the error line.","Replace tabs with spaces and fix indentation/quotes at the reported line.","Ensure you pass the Cilium YAML config (keys/values map), not a raw binary key.","Re-download or regenerate the config if corrupted."],"exampleFix":"# before (tabs cause parse failure)\nkeys:\n\tkey: abc\n# after\nkeys:\n  key: abc","handlingStrategy":"validation","validationCode":"data, _ := os.ReadFile(path)\nvar probe map[string]interface{}\nif err := yaml.Unmarshal(data, &probe); err != nil {\n    return fmt.Errorf(\"invalid YAML at %s: %w\", path, err)\n}\nif !utf8.Valid(data) {\n    return errors.New(\"config is not valid UTF-8 text\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"unable to parse YAML\") {\n    // run yamllint on the file to locate the offending line\n}","preventionTips":["Lint configs with yamllint before use.","Never use tabs in YAML; use spaces.","Confirm the file is the Cilium YAML config, not a binary key.","Round-trip the file through a YAML parser in CI as a pre-check."],"tags":["yaml","parsing","cilium"],"backgroundTag":"yaml-parse-failed","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"}