{"record":{"id":"0c16861fd63234f5","repo":"kubernetes/kops","slug":"field-name-not-found-in-t","errorCode":null,"errorMessage":"field Name not found in %T","messagePattern":"field Name not found in %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/reflectutils/access.go","lineNumber":265,"sourceCode":"\t\t\tnewV = reflect.ValueOf(v32)\n\t\tcase \"uint64\":\n\t\t\tv64 := uint64(v)\n\t\t\tnewV = reflect.ValueOf(v64)\n\t\tdefault:\n\t\t\tpanic(\"missing case in uint switch\")\n\t\t}\n\n\tcase \"intstr.IntOrString\":\n\t\tnewV = reflect.ValueOf(intstr.Parse(newValue))\n\n\tcase \"kops.EnvVar\":\n\t\tnewV = reflect.New(v.Type()).Elem()\n\n\t\tenvVarType := newV.Type()\n\n\t\tfdName, found := envVarType.FieldByName(\"Name\")\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"field Name not found in %T\", newV.Interface())\n\t\t}\n\t\tfdValue, found := envVarType.FieldByName(\"Value\")\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"field Value not found in %T\", newV.Interface())\n\t\t}\n\n\t\tname, value, hasValue := strings.Cut(newValue, \"=\")\n\t\tnewV.FieldByIndex(fdName.Index).SetString(name)\n\t\tif hasValue {\n\t\t\tnewV.FieldByIndex(fdValue.Index).SetString(value)\n\t\t}\n\n\tcase \"v1.Duration\":\n\t\tduration, err := time.ParseDuration(newValue)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot interpret %q value as v1.Duration\", newValue)\n\t\t}\n\t\tnewV = reflect.ValueOf(metav1.Duration{Duration: duration})","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/reflectutils/access.go#L247-L283","documentation":"Inside setType, string values targeting an env-var-style struct are split into Name/Value fields via reflection. If the destination struct type has no exported field named \"Name\", FieldByName fails and this error is returned. This guards against applying an env-var-shaped string to an incompatible struct type.","triggerScenarios":"Calling kops set with a path whose value is treated as an env-var entry (TypeTag \"env-var\") while the resolved struct type lacks a Name field — essentially only possible if the type tag in the struct tag is wrong or the struct definition changed.","commonSituations":"Custom downstream types reusing the reflectutils tags but without Name/Value fields, or an API version change that renamed fields while stale struct tags still declare the env-var type.","solutions":["Verify the struct's reflectutils type tag: fields tagged as env-var must have Name and Value string fields","Update the struct definition to include Name/Value fields, or change the type tag to a matching kind","Use a field path that targets the correct field instead of the whole struct"],"exampleFix":"// before\ntype EnvEntry struct {\n\tKey   string\n\tValue string\n}\n// after\ntype EnvEntry struct {\n\tName  string\n\tValue string\n}","handlingStrategy":"type-guard","validationCode":"t := reflect.TypeOf(targetStruct)\nif _, ok := t.FieldByName(\"Name\"); !ok {\n\treturn fmt.Errorf(\"type %s cannot be used as env-var entry\", t)\n}","typeGuard":"func isEnvVarType(v interface{}) bool {\n\tt := reflect.TypeOf(v)\n\tif t.Kind() == reflect.Ptr { t = t.Elem() }\n\t_, hasName := t.FieldByName(\"Name\")\n\t_, hasValue := t.FieldByName(\"Value\")\n\treturn hasName && hasValue\n}","tryCatchPattern":"if err := Unset/set...; err != nil && strings.Contains(err.Error(), \"field Name not found\") {\n\t// struct schema mismatch; fix type tag or field\n}","preventionTips":["Keep reflectutils type tags in sync with struct definitions","Add unit tests covering set/unset on env-var-tagged fields"],"tags":["reflection","struct-field","go"],"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"}