{"record":{"id":"40903906943a0d22","repo":"kubernetes/kops","slug":"field-s-not-found-in-s","errorCode":null,"errorMessage":"field %s not found in %s","messagePattern":"field (.+?) not found in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/reflectutils/access.go","lineNumber":108,"sourceCode":"\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"unhandled type %v %q\", v.Type().Elem().Kind(), t)\n\t\t\t}\n\n\t\t\tv.Set(newV)\n\t\t\treturn nil\n\n\t\t}\n\n\t\treturn nil\n\t}\n\n\terr = ReflectRecursive(targetValue, visitor, &ReflectOptions{JSONNames: true})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !fieldSet {\n\t\treturn fmt.Errorf(\"field %s not found in %s\", targetPath, BuildTypeName(reflect.TypeOf(target)))\n\t}\n\n\treturn nil\n}\n\nfunc setType(v reflect.Value, newValue string) error {\n\tif !v.CanSet() {\n\t\treturn fmt.Errorf(\"cannot set value\")\n\t}\n\n\tif v.Type().Kind() == reflect.Slice {\n\t\t// To support multiple values, we split on commas.\n\t\t// We have no way to escape a comma currently; but in general we prefer having a slice in the schema,\n\t\t// rather than having values that need to be parsed, so we may not need it.\n\t\ttokens := strings.Split(newValue, \",\")\n\t\tvalueArray := reflect.MakeSlice(v.Type(), 0, v.Len()+len(tokens))\n\t\tvalueArray = reflect.AppendSlice(valueArray, v)\n\t\tfor _, s := range tokens {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/reflectutils/access.go#L90-L126","documentation":"After ReflectRecursive finished walking the target, no visited field path matched targetPath, so fieldSet remained false. This means the requested field path does not exist on the target type (or the JSON name doesn't match). The error names the path and the Go type that was searched.","triggerScenarios":"SetString(target, \"spec.nonExistentField\", \"v\"), misspelled JSON field names, wrong casing (paths use JSON names when JSONNames:true), or targeting a type that doesn't contain the path segment.","commonSituations":"Typo in `kops set cluster spec.X` commands; using Go field names where JSON tags differ; cluster spec fields renamed/removed between kOps versions.","solutions":["Verify the field exists: run `kops get cluster -oyaml` and copy the exact YAML key as the path.","Fix casing/typo in targetPath (JSON names, e.g. spec.kubernetesAPIAccess not KubernetesAPIAccess).","Check the kops API type in pkg/apis/kops for the current field name after upgrades.","Confirm SetString is called on the right root object (cluster vs instancegroup)."],"exampleFix":"// before\nSetString(&cluster, \"spec.KubeAPIServer\", \"...\")   // Go name, wrong\n// after\nSetString(&cluster, \"spec.kubeAPIServer\", \"...\")   // JSON name","handlingStrategy":"validation","validationCode":"func fieldExists(target interface{}, path string) bool {\n    return !strings.Contains(mustSetString(target, path), \"not found\") // or walk with ParseFieldPath + ReflectRecursive read-only\n}","typeGuard":null,"tryCatchPattern":"if err := SetString(&cluster, path, val); err != nil {\n    if strings.Contains(err.Error(), \"not found in\") {\n        return fmt.Errorf(\"unknown field %q for %T; check 'kops get -oyaml' for valid keys\", path, cluster)\n    }\n    return err\n}","preventionTips":["Copy field keys verbatim from `kops get cluster -oyaml` output.","Use JSON tag names, not Go field names.","Re-check field names after kOps version upgrades."],"tags":["go","reflection","field-not-found"],"backgroundTag":"field-not-found","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"}