kubernetes/kops · error
invalid google cloud URL (content after name): %q
Error message
invalid google cloud URL (content after name): %q
What it means
ParseGoogleCloudURL tokenizes a Google Cloud compute resource URL path segment by segment. Once it reaches the resource type token (e.g. disks, instances), it consumes exactly one name token and expects the token list to end. This error is thrown when there are extra path segments after the resource name, meaning the URL does not point to a single named resource.
Source
Thrown at upup/pkg/fi/cloudup/gce/gce_url.go:113
parsed.Zone = tokens[pos]
case t == "regions" && ((pos + 2) < len(tokens)):
pos++
if pos >= len(tokens) {
return nil, fmt.Errorf("invalid google cloud URL (unexpected regions): %q", u)
}
parsed.Region = tokens[pos]
case t == "global":
parsed.Global = true
default:
parsed.Type = tokens[pos]
pos++
if pos >= len(tokens) {
return nil, fmt.Errorf("invalid google cloud URL (no name): %q", u)
}
parsed.Name = tokens[pos]
pos++
if pos != len(tokens) {
return nil, fmt.Errorf("invalid google cloud URL (content after name): %q", u)
} else {
return parsed, nil
}
}
pos++
}
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Print/inspect the offending URL and remove any path segments after the resource name (including trailing slashes).
- Regenerate the self-link from the API object's SelfLink field rather than constructing it manually.
- If parsing a list-style or aggregated URL, use the appropriate list API call instead of ParseGoogleCloudURL.
- Check for double slashes or typos in project/zone segments that shift token positions.
Example fix
// before u := "https://www.googleapis.com/compute/v1/projects/myproj/zones/us-central1-a/disks/mydisk/" _, err := gce.ParseGoogleCloudURL(u) // after u := "https://www.googleapis.com/compute/v1/projects/myproj/zones/us-central1-a/disks/mydisk" _, err := gce.ParseGoogleCloudURL(u)
Defensive patterns
Strategy: validation
Validate before calling
// validate the URL shape before parsing
func validResourceURL(u string) bool {
parsed, err := url.Parse(u)
if err != nil || parsed.Path == "" {
return false
}
segs := strings.Split(strings.Trim(parsed.Path, "/"), "/")
return len(segs) >= 2 && segs[len(segs)-2] != "" && segs[len(segs)-1] != ""
}
if !validResourceURL(selfLink) {
return fmt.Errorf("not a single-resource URL: %q", selfLink)
}
parsed, err := gce.ParseGoogleCloudURL(selfLink) Type guard
func isGoogleComputeSelfLink(s string) bool {
return strings.HasPrefix(s, "https://www.googleapis.com/compute/v1/") || strings.HasPrefix(s, "https://www.googleapis.com/compute/beta/")
} Prevention
- Always take self-links from the API object's SelfLink field, never hand-construct or concatenate them.
- Trim trailing slashes before parsing.
- Store resource name/project/zone separately instead of round-tripping through URLs.
When it happens
Trigger: Passing a URL with trailing path content after the resource name to ParseGoogleCloudURL, e.g. https://www.googleapis.com/compute/v1/projects/p/zones/z/disks/disk-a/extra, a URL for a nested sub-resource, a double slash producing an empty extra token, or a URL with a trailing slash.
Common situations: Dumping cluster state or listing/deleting GCE resources (disks, target pools, forwarding rules, HTTP health checks) when a stored or hand-written self-link is malformed, copied from a sub-resource endpoint, or has a stray trailing slash.
Related errors
- providerID %q not recognized for node %s
- unable to parse instance url %q
- Invalid service account email '%s'
- unable to parse Kubernetes cluster API URL: %v
- error parsing subnet url %q: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/3d71049aac42a831.
Report an issue: GitHub.