{"record":{"id":"c49254165787fee8","repo":"kubernetes/kops","slug":"unknown-write-option-q","errorCode":null,"errorMessage":"unknown write option: %q","messagePattern":"unknown write option: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/client/simple/vfsclientset/commonvfs.go","lineNumber":154,"sourceCode":"\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)\n\t}\n\tif err != nil {\n\t\tif create && os.IsExist(err) {\n\t\t\tklog.Warningf(\"failed to create file as already exists: %v\", configPath)\n\t\t\treturn err","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/client/simple/vfsclientset/commonvfs.go#L136-L172","documentation":"writeConfig only recognizes vfs.WriteOptionNone and vfs.WriteOptionOnlyIfExists. Any other value hits the default branch and returns this error. It is a programming/API-misuse error in the caller, not an environment issue.","triggerScenarios":"Code passes an unrecognized vfs.WriteOption value to Create, Update, create, or update on a VFS-backed clientset — e.g. a new vfs option not yet handled in writeConfig, or a typo'd constant.","commonSituations":"Upgrading the vfs package introduces a new WriteOption this vfsclientset does not handle; custom forks adding options; passing the wrong constant.","solutions":["Inspect the writeOption value being passed and change it to vfs.WriteOptionNone or vfs.WriteOptionOnlyIfExists.","If a new option is required, add a case for it in writeConfig in commonvfs.go.","Ensure vfs and vfsclientset package versions are consistent (go mod tidy)."],"exampleFix":"// before\nerr := c.writeConfig(ctx, cluster, p, obj, vfs.WriteOptionIgnoreExisting)\n// after\nerr := c.writeConfig(ctx, cluster, p, obj, vfs.WriteOptionNone)","handlingStrategy":"validation","validationCode":"allowed := map[vfs.WriteOption]bool{vfs.WriteOptionNone: true, vfs.WriteOptionOnlyIfExists: true}\nif !allowed[opt] {\n    return fmt.Errorf(\"unsupported write option %v\", opt)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use documented vfs.WriteOption constants","Keep vfs and vfsclientset package versions in sync","Add unit tests covering each write option branch"],"tags":["vfs","api-misuse","programming-error"],"backgroundTag":"invalid-enum-value","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"}