kubernetes/kops · error

field Value not found in %T

Error message

field Value not found in %T

What it means

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.

Source

Thrown at util/pkg/reflectutils/access.go:269

		default:
			panic("missing case in uint switch")
		}

	case "intstr.IntOrString":
		newV = reflect.ValueOf(intstr.Parse(newValue))

	case "kops.EnvVar":
		newV = reflect.New(v.Type()).Elem()

		envVarType := newV.Type()

		fdName, found := envVarType.FieldByName("Name")
		if !found {
			return fmt.Errorf("field Name not found in %T", newV.Interface())
		}
		fdValue, found := envVarType.FieldByName("Value")
		if !found {
			return fmt.Errorf("field Value not found in %T", newV.Interface())
		}

		name, value, hasValue := strings.Cut(newValue, "=")
		newV.FieldByIndex(fdName.Index).SetString(name)
		if hasValue {
			newV.FieldByIndex(fdValue.Index).SetString(value)
		}

	case "v1.Duration":
		duration, err := time.ParseDuration(newValue)
		if err != nil {
			return fmt.Errorf("cannot interpret %q value as v1.Duration", newValue)
		}
		newV = reflect.ValueOf(metav1.Duration{Duration: duration})

	case "resource.Quantity":
		quantity, err := resource.ParseQuantity(newValue)
		if err != nil {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Ensure the struct tagged as env-var has both Name and Value string fields
  2. Correct or remove the stale type tag on the struct
  3. Target an individual existing field via the field path instead of the whole env entry

Example fix

// before
type EnvEntry struct {
	Name string
}
// after
type EnvEntry struct {
	Name  string
	Value string
}
Defensive patterns

Strategy: type-guard

Validate before calling

t := reflect.TypeOf(targetStruct)
if _, ok := t.FieldByName("Value"); !ok {
	return fmt.Errorf("type %s lacks Value field for env entries", t)
}

Type guard

func hasEnvValueField(v interface{}) bool {
	t := reflect.TypeOf(v)
	if t.Kind() == reflect.Ptr { t = t.Elem() }
	_, ok := t.FieldByName("Value")
	return ok
}

Try / catch

if err := doSet(); err != nil && strings.Contains(err.Error(), "field Value not found") {
	// env-var struct schema mismatch; correct struct or tag
}

Prevention

When it happens

Trigger: 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.

Common situations: Struct definitions that only have a Name field, or renamed fields after an API version change while the env-var type tag remained.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/bd0cbe3ec74b17ae. Report an issue: GitHub.