kubernetes/kops · error

unhandled mode %q

Error message

unhandled mode %q

What it means

Defensive default-case error from Network.RenderGCE during creation. CheckChanges should have filtered invalid modes already, so reaching this branch means the mode switch was extended inconsistently (or mode validation was bypassed) — the printed mode has no creation handling.

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/network.go:172

		}

		switch e.Mode {
		case "legacy":
			network.IPv4Range = fi.ValueOf(e.CIDR)

		case "auto":
			network.AutoCreateSubnetworks = true

		case "custom":
			network.AutoCreateSubnetworks = false
			// The boolean default value of "false" is omitted when the struct
			// is serialized, which results in the network being created with
			// the auto-create subnetworks default of "true". Explicitly send
			// the default value.
			network.ForceSendFields = []string{"AutoCreateSubnetworks"}

		default:
			return fmt.Errorf("unhandled mode %q", e.Mode)
		}

		op, err := t.Cloud.Compute().Networks().Insert(t.Cloud.Project(), network)
		if err != nil {
			return fmt.Errorf("error creating Network: %v", err)
		}
		if err := t.Cloud.WaitForOp(op); err != nil {
			return fmt.Errorf("error waiting for Network creation to complete: %w", err)
		}
	} else {
		if a.Mode == "legacy" {
			return fmt.Errorf("GCE networks in legacy mode are not supported.  Please convert to auto mode or specify a different network.")
		}
		empty := &Network{}
		if !reflect.DeepEqual(empty, changes) {
			return fmt.Errorf("cannot apply changes to Network: %v", changes)
		}
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Use one of the supported modes (auto, custom, legacy) in the network spec
  2. Report as a kOps bug if the mode passed validation but has no create path
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/gcetasks/network.go:172 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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