kubernetes/kops · error

invalid google cloud URL (unexpected end): %q

Error message

invalid google cloud URL (unexpected end): %q

What it means

Loop-stage parse guard in ParseGoogleCloudURL: while walking path segments (projects/zones/regions/global/type/name), the tokens ran out before a complete resource could be parsed — e.g. the URL ends right after a keyword or the resource type without a name.

Source

Thrown at upup/pkg/fi/cloudup/gce/gce_url.go:80

	if tokens[0] != "https:" || tokens[1] != "" || tokens[2] != "www.googleapis.com" {
		return nil, fmt.Errorf("invalid google cloud URL (schema / host): %q", u)
	}

	if len(tokens) < 5 || tokens[3] != "compute" {
		return nil, fmt.Errorf("invalid google cloud URL (not compute): %q", u)
	}

	if tokens[4] != "v1" && tokens[4] != "beta" {
		return nil, fmt.Errorf("invalid google cloud URL (not compute/v1 or compute/beta): %q", u)
	}

	parsed := &GoogleCloudURL{
		Version: tokens[4],
	}
	pos := 5
	for {
		if pos >= len(tokens) {
			return nil, fmt.Errorf("invalid google cloud URL (unexpected end): %q", u)
		}
		t := tokens[pos]
		switch {
		case t == "projects":
			pos++
			if pos >= len(tokens) {
				return nil, fmt.Errorf("invalid google cloud URL (unexpected projects): %q", u)
			}
			parsed.Project = tokens[pos]
		case t == "zones":
			pos++
			if pos >= len(tokens) {
				return nil, fmt.Errorf("invalid google cloud URL (unexpected zones): %q", u)
			}
			parsed.Zone = tokens[pos]
		case t == "regions" && ((pos + 2) < len(tokens)):
			pos++
			if pos >= len(tokens) {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Provide the complete self-link including resource type and name
  2. Check for truncated URLs
  3. Fix the source value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/gce/gce_url.go:80 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/818e6cc2bf1e5599. Report an issue: GitHub.