{"record":{"id":"6159bf2ceec4a6b0","repo":"kubernetes/kops","slug":"error-parsing-s-v","errorCode":null,"errorMessage":"error parsing %s: %v","messagePattern":"error parsing (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/client/simple/vfsclientset/commonvfs.go","lineNumber":129,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error encoding object: %v\", err)\n\t}\n\n\treturn b.Bytes(), nil\n}\n\nfunc (c *VFSClientBase) readConfig(ctx context.Context, configPath vfs.Path) (runtime.Object, error) {\n\tdata, err := configPath.ReadFile(ctx)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, fmt.Errorf(\"error reading %s: %v\", configPath, err)\n\t}\n\n\tobject, _, err := kopscodecs.Decode(data, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing %s: %v\", configPath, err)\n\t}\n\treturn object, nil\n}\n\nfunc (c *VFSClientBase) writeConfig(ctx context.Context, cluster *kops.Cluster, configPath vfs.Path, o runtime.Object, writeOptions ...vfs.WriteOption) error {\n\tdata, err := c.serialize(o)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshaling object: %v\", err)\n\t}\n\n\tcreate := false\n\tfor _, writeOption := range writeOptions {\n\t\tswitch writeOption {\n\t\tcase vfs.WriteOptionCreate:\n\t\t\tcreate = true\n\t\tcase vfs.WriteOptionOnlyIfExists:\n\t\t\t_, err = configPath.ReadFile(ctx)\n\t\t\tif err != nil {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/client/simple/vfsclientset/commonvfs.go#L111-L147","documentation":"readConfig() successfully read the object's bytes but kopscodecs.Decode could not parse them into a runtime.Object. This indicates the stored manifest is corrupt, empty, in an unrecognized format, or from an incompatible schema version.","triggerScenarios":"Find/Get on a vfs clientset where the file exists but its contents fail kopscodecs.Decode — truncated upload, YAML/JSON not matching kops API, unknown apiVersion, or manual edits.","commonSituations":"Manually edited YAML in the S3 state bucket with wrong apiVersion; interrupted `kops replace`/upload leaving a partial file; kops version upgrade changing codecs; garbage/corruption in the bucket object.","solutions":["Download the offending file from the state store and inspect it for corruption or wrong apiVersion.","Fix or restore the manifest (e.g. via `kops get -o yaml` from a backup, or git-versioned copy).","Ensure the kops CLI version is compatible with the cluster state version.","Re-upload the file with a valid kops API version (e.g. kops.k8s.io/v1alpha2 as appropriate)."],"exampleFix":"// before (state store file)\napiVersion: v1alpha1  # unknown to current codecs\nkind: Cluster\n// after\napiVersion: kops.k8s.io/v1alpha2\nkind: Cluster","handlingStrategy":"validation","validationCode":"data, err := readRawFromStateStore(ctx, path)\nif err != nil { return err }\nif len(bytes.TrimSpace(data)) == 0 {\n    return fmt.Errorf(\"state file %s is empty/corrupt\", path)\n}\nif !bytes.Contains(data, []byte(\"apiVersion:\")) {\n    return fmt.Errorf(\"state file %s is not a kubernetes-style manifest\", path)\n}","typeGuard":null,"tryCatchPattern":"if err := client.Get(ctx, name); err != nil && strings.Contains(err.Error(), \"error parsing\") {\n    // restore the manifest from backup before retrying\n}","preventionTips":["Never hand-edit manifests in the state store; use `kops replace -f`.","Keep state store objects version-controlled/backed up.","Avoid interrupting write operations; verify uploads completed.","Match kops CLI version to cluster state version."],"tags":["vfs","parsing","codec","corrupt-state"],"backgroundTag":"manifest-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"}