{"record":{"id":"bd0cbe3ec74b17ae","repo":"kubernetes/kops","slug":"field-value-not-found-in-t","errorCode":null,"errorMessage":"field Value not found in %T","messagePattern":"field Value not found in %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/reflectutils/access.go","lineNumber":269,"sourceCode":"\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})\n\n\tcase \"resource.Quantity\":\n\t\tquantity, err := resource.ParseQuantity(newValue)\n\t\tif err != nil {","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/reflectutils/access.go#L251-L287","documentation":"Companion to the Name-field check: when converting a string into an env-var-shaped struct, setType requires a \"Value\" field. If FieldByName(\"Value\") fails, this error is returned. It means the destination struct is not a valid env-var entry type despite its type tag.","triggerScenarios":"Same as the Name check: applying a `name=value` string via kops set to a struct tagged with the env-var type tag whose type has no Value field.","commonSituations":"Struct definitions that only have a Name field, or renamed fields after an API version change while the env-var type tag remained.","solutions":["Ensure the struct tagged as env-var has both Name and Value string fields","Correct or remove the stale type tag on the struct","Target an individual existing field via the field path instead of the whole env entry"],"exampleFix":"// before\ntype EnvEntry struct {\n\tName 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(\"Value\"); !ok {\n\treturn fmt.Errorf(\"type %s lacks Value field for env entries\", t)\n}","typeGuard":"func hasEnvValueField(v interface{}) bool {\n\tt := reflect.TypeOf(v)\n\tif t.Kind() == reflect.Ptr { t = t.Elem() }\n\t_, ok := t.FieldByName(\"Value\")\n\treturn ok\n}","tryCatchPattern":"if err := doSet(); err != nil && strings.Contains(err.Error(), \"field Value not found\") {\n\t// env-var struct schema mismatch; correct struct or tag\n}","preventionTips":["Ensure env-entry structs always define both Name and Value string fields","Test schema changes against kops set code paths"],"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"}