kubernetes/kops · error
field %s not found in %s
Error message
field %s not found in %s
What it means
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.
Source
Thrown at util/pkg/reflectutils/access.go:108
default:
return fmt.Errorf("unhandled type %v %q", v.Type().Elem().Kind(), t)
}
v.Set(newV)
return nil
}
return nil
}
err = ReflectRecursive(targetValue, visitor, &ReflectOptions{JSONNames: true})
if err != nil {
return err
}
if !fieldSet {
return fmt.Errorf("field %s not found in %s", targetPath, BuildTypeName(reflect.TypeOf(target)))
}
return nil
}
func setType(v reflect.Value, newValue string) error {
if !v.CanSet() {
return fmt.Errorf("cannot set value")
}
if v.Type().Kind() == reflect.Slice {
// To support multiple values, we split on commas.
// We have no way to escape a comma currently; but in general we prefer having a slice in the schema,
// rather than having values that need to be parsed, so we may not need it.
tokens := strings.Split(newValue, ",")
valueArray := reflect.MakeSlice(v.Type(), 0, v.Len()+len(tokens))
valueArray = reflect.AppendSlice(valueArray, v)
for _, s := range tokens {View on GitHub (pinned to 4c8573c808)
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).
Example fix
// before SetString(&cluster, "spec.KubeAPIServer", "...") // Go name, wrong // after SetString(&cluster, "spec.kubeAPIServer", "...") // JSON name
Defensive patterns
Strategy: validation
Validate before calling
func fieldExists(target interface{}, path string) bool {
return !strings.Contains(mustSetString(target, path), "not found") // or walk with ParseFieldPath + ReflectRecursive read-only
} Try / catch
if err := SetString(&cluster, path, val); err != nil {
if strings.Contains(err.Error(), "not found in") {
return fmt.Errorf("unknown field %q for %T; check 'kops get -oyaml' for valid keys", path, cluster)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Typo in `kops set cluster spec.X` commands; using Go field names where JSON tags differ; cluster spec fields renamed/removed between kOps versions.
Related errors
- conversion error for field %s: %s
- unable to convert from Quantity %v to float
- BuildFlagsList to reflect value: %s
- only accepts structs; got %T
- unhandled type %v %q
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/40903906943a0d22.
Report an issue: GitHub.