{"record":{"id":"158de1b09106bbfa","repo":"kubernetes/kops","slug":"error-parsing-file-q-v","errorCode":null,"errorMessage":"error parsing file %q: %v","messagePattern":"error parsing file %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create.go","lineNumber":129,"sourceCode":"\tfor _, f := range c.Filenames {\n\t\tvar contents []byte\n\t\tif f == \"-\" {\n\t\t\tcontents, err = ConsumeStdin()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\tcontents, err = vfsContext.ReadFile(f)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error reading file %q: %v\", f, err)\n\t\t\t}\n\t\t}\n\t\t// TODO: this does not support a JSON array\n\t\tsections := text.SplitContentToSections(contents)\n\t\tfor _, section := range sections {\n\t\t\to, gvk, err := kopscodecs.Decode(section, nil)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error parsing file %q: %v\", f, err)\n\t\t\t}\n\n\t\t\tswitch v := o.(type) {\n\t\t\tcase *kopsapi.Cluster:\n\t\t\t\tcloud, err := cloudup.BuildCloud(v)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\t// Adding a PerformAssignments() call here as the user might be trying to use\n\t\t\t\t// the new `-f` feature, with an old cluster definition.\n\t\t\t\terr = cloudup.PerformAssignments(v, vfsContext, cloud)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error populating configuration: %v\", err)\n\t\t\t\t}\n\t\t\t\t_, err = clientset.CreateCluster(ctx, v)\n\t\t\t\tif err != nil {\n\t\t\t\t\tif apierrors.IsAlreadyExists(err) {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create.go#L111-L147","documentation":"RunCreate splits each input file into YAML sections and decodes them with the kops codecs; this fires when a section cannot be decoded as a known kops object. The file was read successfully, so the problem is its content: invalid YAML structure or an unrecognized kind.","triggerScenarios":"`kops create -f` given a manifest that is not a valid kops resource: wrong apiVersion/kind, invalid YAML/JSON syntax, unknown fields causing strict decode failure, or a spec from a newer kOps version.","commonSituations":"Hand-written cluster/instancegroup YAML with indentation errors; manifests exported from a newer kOps; using a Kubernetes resource YAML (e.g. a Deployment) instead of a kops resource; missing kind or apiVersion.","solutions":["Validate the YAML/JSON syntax (yamllint) and ensure each document has a kops apiVersion and kind (e.g. kops.k8s.io/v1alpha2, Cluster)","Match the manifest schema to your kops CLI version; upgrade kops if the file uses newer fields","Test decode with `kops toolbox dump` or `kops get -f` round-trip; fix fields flagged in the wrapped error message"],"exampleFix":"// before\nkind: Cluser\napiVersion: v1alpha2\n// after\nkind: Cluster\napiVersion: kops.k8s.io/v1alpha2","handlingStrategy":"validation","validationCode":"// validate syntax and required headers before kops create\nsections := text.SplitContentToSections(contents)\nfor _, s := range sections {\n    var probe map[string]interface{}\n    if err := yaml.Unmarshal(s, &probe); err != nil {\n        return fmt.Errorf(\"invalid YAML: %v\", err)\n    }\n    if probe[\"kind\"] == nil || probe[\"apiVersion\"] == nil {\n        return fmt.Errorf(\"manifest missing kind/apiVersion\")\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, _, err := kopscodecs.Decode(section, nil); err != nil {\n    // print offending section and schema version expected by kops\n    log.Printf(\"decode failed for %q: %v\", f, err)\n}","preventionTips":["Generate manifests with `kops create cluster`/`kops get -o yaml` rather than writing by hand","Lint manifests with yamllint and match apiVersion to your kops binary version","Keep each YAML document a single kops resource (arrays unsupported)","Round-trip with `kops get -f` in CI before create"],"tags":["cli","yaml","parsing","schema-validation"],"backgroundTag":"schema-validation-failed","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"}