{"record":{"id":"1f7d4c6cbfcc77c1","repo":"kubernetes/kops","slug":"cannot-update-configuration-file-s-does-not-exis","errorCode":null,"errorMessage":"cannot update configuration file %s: does not exist","messagePattern":"cannot update configuration file (.+?): does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/client/simple/vfsclientset/commonvfs.go","lineNumber":149,"sourceCode":"\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 {\n\t\t\t\tif os.IsNotExist(err) {\n\t\t\t\t\treturn fmt.Errorf(\"cannot update configuration file %s: does not exist\", configPath)\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"error checking if configuration file %s exists already: %v\", configPath, err)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown write option: %q\", writeOption)\n\t\t}\n\t}\n\n\tacl, err := acls.GetACL(ctx, configPath, cluster)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trs := bytes.NewReader(data)\n\tif create {\n\t\terr = configPath.CreateFile(ctx, rs, acl)\n\t} else {\n\t\terr = configPath.WriteFile(ctx, rs, acl)","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/client/simple/vfsclientset/commonvfs.go#L131-L167","documentation":"writeConfig() was invoked with vfs.WriteOptionOnlyIfExists (an update path) but a pre-flight ReadFile confirmed the configuration file does not exist in the state store. Updates are only allowed on existing objects, so this guards against silently creating a file via update.","triggerScenarios":"Update()/update() on a vfs clientset where the object file at basePath.Join(name) is missing — updating a cluster that was never created or was deleted.","commonSituations":"Running `kops update cluster` after `kops delete cluster` or with a mistyped cluster name; wrong KOPS_STATE_STORE so the object appears missing; racing deletion and update operations.","solutions":["Verify the cluster/object name spelling and the KOPS_STATE_STORE bucket are correct.","Check the file exists: `aws s3 ls $KOPS_STATE_STORE/<name>/cluster/spec` (or equivalent path).","Create the object first with Create instead of Update if it genuinely doesn't exist.","Restore from backup if the state store object was deleted unintentionally."],"exampleFix":"// before\nkops update cluster --name typo.example.com\n// after\nkops get clusters  # list actual cluster names\nkops update cluster --name prod.example.com","handlingStrategy":"validation","validationCode":"existing, err := client.Find(ctx, name)\nif err != nil { return err }\nif existing == nil {\n    return fmt.Errorf(\"object %q does not exist in state store; use Create instead of Update\", name)\n}","typeGuard":null,"tryCatchPattern":"err := client.Update(ctx, obj)\nif err != nil && strings.Contains(err.Error(), \"does not exist\") {\n    // create it first or correct the name/state store\n}","preventionTips":["Always Get/Find the object before calling Update.","Double-check cluster name spelling and KOPS_STATE_STORE.","Avoid racing delete and update operations on the same cluster."],"tags":["vfs","update","not-exist","state-store"],"backgroundTag":"update-nonexistent-object","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"}