GoogleContainerTools/skaffold · warning

invalid default struct tag: %v, expected key=value

Error message

invalid default struct tag: %v, expected key=value

What it means

oneOfTag.Load parses a `oneOf=groupName,defaultField` style struct tag; it expects exactly two tokens after splitting on '='. If the tag doesn't have the form key=value, Load returns 'invalid default struct tag: %v, expected key=value'. This is a compile-time-style misconfiguration in the struct definitions the config schemas rely on.

Source

Thrown at pkg/skaffold/yamltags/tags.go:206

func getOneOfSetsForStruct(structName string) map[string]fieldSet {
	_, ok := allOneOfs[structName]
	if !ok {
		allOneOfs[structName] = map[string]fieldSet{}
	}
	return allOneOfs[structName]
}

type oneOfTag struct {
	Field     reflect.StructField
	Parent    reflect.Value
	oneOfSets map[string]fieldSet
	setName   string
}

func (oot *oneOfTag) Load(s []string) error {
	if len(s) != 2 {
		return fmt.Errorf("invalid default struct tag: %v, expected key=value", s)
	}
	oot.setName = s[1]

	// Fetch the right oneOfSet for the struct.
	structName := oot.Parent.Type().Name()
	oot.oneOfSets = getOneOfSetsForStruct(structName)

	// Add this field to the oneOfSet
	if _, ok := oot.oneOfSets[oot.setName]; !ok {
		oot.oneOfSets[oot.setName] = fieldSet{}
	}
	oot.oneOfSets[oot.setName][oot.Field.Name] = struct{}{}
	return nil
}

func (oot *oneOfTag) Process(val reflect.Value) error {
	if isZeroValue(val) {
		return nil

View on GitHub (pinned to a1189de023)

Solutions

  1. Fix the struct tag to the exact `oneOf=SetName=DefaultField` key=value form (split must yield 2 parts)
  2. Check for stray '=' characters or trailing whitespace in the tag string
  3. Compare the tag with a working example in pkg/skaffold/apm/verify/latest (existing oneOf usages)
  4. If you only see this at runtime, rebuild/reinstall Skaffold from a clean source tree — you may have local edits

Example fix

// before (struct tag)
Deploy `json:"deploy" yaml:"deploy" oneOf:"deploy"`   // splits to 1 part
// after
Deploy `json:"deploy" yaml:"deploy" oneOf="config=deploy"`   // key=value
Defensive patterns

Strategy: validation

Validate before calling

func validOneOfTag(tag string) bool {
    parts := strings.Split(tag, "=")
    return len(parts) == 2 && parts[0] != "" && parts[1] != ""
}

Type guard

func hasOneOfTag(f reflect.StructField) (string, bool) {
    t, ok := f.Tag.Lookup("oneOf")
    return t, ok && len(strings.Split(t, "=")) == 2
}

Try / catch

if err := oot.Load(parts); err != nil {
    // log full field/tag (reflect) and fail fast at config-load time
}

Prevention

When it happens

Trigger: A struct field's oneOf tag splits into a slice with len != 2 (e.g. `oneOf:"deploy"` with no default, extra '=', or stray whitespace), hit when the yamltags loader builds the tag during config struct loading/validation.

Common situations: Usually surfaced only when Skaffold's own config structs or a downstream project reusing pkg/skaffold/yamltags has a malformed tag; contributors adding new config fields typo the tag (missing default, `oneOf:"oneOf:"`, comma vs equals mixups).

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/b06a25700e2b6cb2. Report an issue: GitHub.