kubernetes/kops · error
cannot create request: %v
Error message
cannot create request: %v
What it means
Thrown by OpenURL when http.NewRequestWithContext rejects the URL while building the GET request. Go's request builder fails on URLs it cannot parse — missing scheme, control characters, or a malformed URL string — so this is an invalid-URL error surfacing before any network traffic.
Source
Thrown at upup/pkg/fi/http.go:148
actual := &hashing.Hash{
Algorithm: algorithm,
HashValue: hasher.Sum(nil),
}
if hash != nil && !actual.Equal(hash) {
return nil, fmt.Errorf("downloaded from %q but hash did not match expected %q", desturl, hash)
}
return actual, nil
}
// OpenURL opens a hardened HTTP GET stream for url.
func OpenURL(url string) (io.ReadCloser, error) {
httpClient := newDownloadHTTPClient()
ctx, cancel := context.WithTimeout(context.Background(), downloadTimeout)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
cancel()
return nil, fmt.Errorf("cannot create request: %v", err)
}
response, err := httpClient.Do(req)
if err != nil {
cancel()
return nil, fmt.Errorf("error doing HTTP fetch of %q: %v", url, err)
}
// http.Client follows 3xx automatically, so anything outside 2xx that reaches us is a bug or a missing Location.
if response.StatusCode < 200 || response.StatusCode > 299 {
response.Body.Close()
cancel()
return nil, fmt.Errorf("unexpected response from %q: HTTP %s", url, response.Status)
}
return &cancelOnCloseReadCloser{ReadCloser: response.Body, cancel: cancel}, nil
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Fix the URL string: include the scheme (https://) and encode spaces/control characters
- Check where the URL was composed (spec field, environment variable) for truncation or templating mistakes
- Validate URLs with url.Parse before passing them to download helpers
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at upup/pkg/fi/http.go:148 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/1f0b0465dc4344db.
Report an issue: GitHub.