kubernetes/kops · error
unable to parse argument %q as url
Error message
unable to parse argument %q as url
What it means
buildMenu parses the channel location with url.Parse; if parsing fails, 'unable to parse argument %q as url' is returned. A parseable but relative URL is also rejected, but via the separate legacy-addon deprecation error (index 78).
Source
Thrown at channels/pkg/cmd/apply_channel.go:335
}
channelVersions := make(map[string]*channels.ChannelVersion)
for i := range namespaces.Items {
ns := &namespaces.Items[i]
addons := channels.FindChannelVersions(ns)
for name, version := range addons {
channelVersions[ns.Name+":"+name] = version
}
}
return channelVersions, nil
}
func buildMenu(vfsContext *vfs.VFSContext, kubernetesVersion semver.Version, channelLocation string) (*channels.AddonMenu, error) {
menu := channels.NewAddonMenu()
location, err := url.Parse(channelLocation)
if err != nil {
return nil, fmt.Errorf("unable to parse argument %q as url", channelLocation)
}
if !location.IsAbs() {
expanded := "https://raw.githubusercontent.com/kubernetes/kops/master/addons/" + channelLocation + "/addon.yaml"
// Disallow the use of legacy addons from the "well-known" location starting Kubernetes 1.23:
// https://raw.githubusercontent.com/kubernetes/kops/master/addons/<name>/addon.yaml
return nil, fmt.Errorf("legacy addons are deprecated and unmaintained, use managed addons instead of %s", expanded)
}
o, err := channels.LoadAddons(vfsContext, channelLocation, location)
if err != nil {
return nil, fmt.Errorf("error loading channel %q: %v", location, err)
}
current, err := o.GetCurrent(kubernetesVersion)
if err != nil {
return nil, fmt.Errorf("error processing latest versions in %q: %v", location, err)
}
menu.MergeAddons(current)
return menu, nilView on GitHub (pinned to 4c8573c808)
Solutions
- Quote and re-check the argument; remove invalid characters
- Use a fully-qualified absolute https:// URL to the addon.yaml
- For bare addon names, switch to kOps managed addons in the cluster spec
- Sanity-check the URL with any standard URL parser before running
Example fix
// before kops apply channel "https://example.com/addons/ my addon/addon.yaml" // after kops apply channel "https://example.com/addons/my-addon/addon.yaml"
Defensive patterns
Strategy: validation
Validate before calling
if _, err := url.Parse(channelLocation); err != nil {
return fmt.Errorf("channel location %q is not a valid URL", channelLocation)
} Type guard
func isParseableURL(s string) bool {
_, err := url.Parse(s)
return err == nil
} Try / catch
if _, err := url.Parse(arg); err != nil {
return fmt.Errorf("rejecting invalid channel argument %q: %v", arg, err)
} Prevention
- Quote all channel arguments in shell scripts
- Avoid uncontrolled variable interpolation into URLs
- Lint CLI arguments for spaces/control characters before invoking
When it happens
Trigger: Passing a channel argument with characters invalid for a URL (spaces, control chars, malformed scheme) to `kops apply channel`.
Common situations: Typos in the URL, shell interpolation injecting spaces/newlines, quoting mistakes leaving stray characters, passing a bare addon name expecting legacy behavior.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- too many arguments
- cannot mix --name for cluster with positional arguments
- unknown output format: %q
- must specify name of keyset promote keypair in
- can only promote to one keyset at a time
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/590196928ca52f1d.
Report an issue: GitHub.