kubernetes/kops · error

BuildFlagsList to reflect value: %s

Error message

BuildFlagsList to reflect value: %s

What it means

BuildFlagsList walks the options struct recursively using reflectutils.ReflectRecursive. Any error returned by the walker (unparseable flag spec, unhandled value type, reflection failures) is wrapped here as 'BuildFlagsList to reflect value: ...'. The original cause is embedded in the message.

Source

Thrown at pkg/flagbuilder/build_flags.go:213

		case resource.Quantity:
			// Format as a floating point value (i.e. 3.14, not 3140m)
			vString := v.AsDec().String()
			if vString != flagEmpty {
				flag = fmt.Sprintf("--%s=%s", flagName, vString)
			}

		default:
			return fmt.Errorf("BuildFlagsList of value type not handled: %T %s=%v", v, path, v)
		}
		if flag != "" {
			flags = append(flags, flag)
		}

		return reflectutils.SkipReflection
	}
	err := reflectutils.ReflectRecursive(reflect.ValueOf(options), walker, &reflectutils.ReflectOptions{DeprecatedDoubleVisit: true})
	if err != nil {
		return nil, fmt.Errorf("BuildFlagsList to reflect value: %s", err)
	}
	// Sort so that the order is stable across runs
	sort.Strings(flags)

	return flags, nil
}

// maybeQuote quotes s when it contains a double quote, so values survive the space-separated
// string form that a shell or systemd may parse. argv values use neverQuote instead.
func maybeQuote(s string) string {
	if strings.Contains(s, "\"") {
		return fmt.Sprintf("%q", s)
	}
	return s
}

// neverQuote returns s unchanged, for values used directly as exec argv.
func neverQuote(s string) string {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the inner error after the prefix to identify the offending field/path
  2. Fix the underlying tag or type issue reported by the wrapped error
  3. Check the field at the path shown in the wrapped message against supported flag types
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate options struct tags/types before reflection to surface root causes early
if err := validateFlagTags(opts); err != nil {
	return fmt.Errorf("options invalid before BuildFlagsList: %w", err)
}

Try / catch

flags, err := flagbuilder.BuildFlagsList(opts)
if err != nil {
	var inner error
	if strings.HasPrefix(err.Error(), "BuildFlagsList to reflect value:") {
		inner = fmt.Errorf("%s", strings.TrimPrefix(err.Error(), "BuildFlagsList to reflect value: "))
		return fmt.Errorf("flagbuilder walker failed: %w", inner)
	}
	return err
}

Prevention

When it happens

Trigger: Any underlying walker error (errors 1110-1113, or an internal reflectutils failure) while reflecting the options object passed to BuildFlags/BuildFlagsList.

Common situations: Debugging a wrapped error and seeing only this prefix; it typically appears when a newly added config field has an unsupported type or malformed tag.

Related errors


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