{"record":{"id":"026cfff2c9e69d16","repo":"kubernetes/kops","slug":"error-parsing-configuration-v","errorCode":null,"errorMessage":"error parsing configuration: %v","messagePattern":"error parsing configuration: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apis/kops/parse.go","lineNumber":66,"sourceCode":"\n\tif lenient && strings.ToLower(findRole) == \"master\" {\n\t\treturn InstanceGroupRoleControlPlane, true\n\t}\n\n\treturn \"\", false\n}\n\n// ParseRawYaml parses an object just using yaml, without the full api machinery\n// Deprecated: prefer using the API machinery (package kopscodecs)\nfunc ParseRawYaml(data []byte, dest interface{}) error {\n\t// Yaml can't parse empty strings\n\tconfigString := string(data)\n\tconfigString = strings.TrimSpace(configString)\n\n\tif configString != \"\" {\n\t\terr := yaml.Unmarshal([]byte(configString), dest, yaml.DisallowUnknownFields)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error parsing configuration: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// ToRawYaml marshals an object to yaml, without the full api machinery\n// Deprecated: prefer using the API machinery (package kopscodecs)\nfunc ToRawYaml(obj interface{}) ([]byte, error) {\n\tdata, err := utils.YamlMarshal(obj)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error converting to yaml: %v\", err)\n\t}\n\n\treturn data, nil\n}\n","sourceCodeStart":48,"sourceCodeEnd":83,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/apis/kops/parse.go#L48-L83","documentation":"ParseRawYaml unmarshals a YAML document into dest using sigs.k8s.io/yaml with yaml.DisallowUnknownFields. Any syntax error in the YAML, or any field in the document that does not exist on the destination struct, produces this wrapped error. The inner %v carries the precise yaml error (line number and offending field).","triggerScenarios":"Calling ParseRawYaml (or its callers ParseChannel, RunCreateSecretEncryptionConfig, RunCreateSecretCiliumEncryptionConfig) with: (1) malformed YAML — bad indentation, tabs, unbalanced quotes; (2) an unknown/misspelled field in the document; (3) a type mismatch (string where int is expected).","commonSituations":"Editing a kops channel or encryptionconfig manifest by hand and introducing an indentation slip; upgrading kOps where a field was renamed/removed so old manifests now contain unknown fields; copying examples with tabs instead of spaces; pasting config from another tool with extra fields.","solutions":["Read the inner error message (%v) — it names the exact line and field; fix that line in the YAML file.","Replace tabs with spaces and fix indentation of the offending block.","Remove or correct misspelled/unknown fields; check `kops get cluster -o yaml` for the accepted schema.","If caused by a kOps upgrade, migrate the manifest to the current API fields or pin the older kOps version."],"exampleFix":"// before\nspec:\n\tencryptionConfig: true   # tab indentation -> parse error\n// after\nspec:\n  encryptionConfig: true","handlingStrategy":"try-catch","validationCode":"// Pre-validate YAML before ParseRawYaml\nvar probe map[string]interface{}\nif err := yaml.Unmarshal(data, &probe); err != nil {\n\treturn fmt.Errorf(\"invalid YAML: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := kops.ParseRawYaml(data, dest); err != nil {\n\tvar detail string\n\tfmt.Sscanf(err.Error(), \"error parsing configuration: %s\", &detail)\n\tlog.Fatalf(\"config file invalid, fix this first: %s\", detail)\n}","preventionTips":["Lint YAML files with yamllint or an editor YAML plugin before use.","Use spaces, never tabs, for indentation.","After kOps upgrades, diff your manifests against `kops get -o yaml` output for renamed/removed fields.","Keep manifests under schema validation (kubeconform-style or kops tooling) in CI."],"tags":["yaml","parsing","configuration","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-12T07:17:12.445Z"}