{"record":{"id":"1f0b0465dc4344db","repo":"kubernetes/kops","slug":"cannot-create-request-v","errorCode":null,"errorMessage":"cannot create request: %v","messagePattern":"cannot create request: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/http.go","lineNumber":148,"sourceCode":"\tactual := &hashing.Hash{\n\t\tAlgorithm: algorithm,\n\t\tHashValue: hasher.Sum(nil),\n\t}\n\tif hash != nil && !actual.Equal(hash) {\n\t\treturn nil, fmt.Errorf(\"downloaded from %q but hash did not match expected %q\", desturl, hash)\n\t}\n\treturn actual, nil\n}\n\n// OpenURL opens a hardened HTTP GET stream for url.\nfunc OpenURL(url string) (io.ReadCloser, error) {\n\thttpClient := newDownloadHTTPClient()\n\n\tctx, cancel := context.WithTimeout(context.Background(), downloadTimeout)\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)\n\tif err != nil {\n\t\tcancel()\n\t\treturn nil, fmt.Errorf(\"cannot create request: %v\", err)\n\t}\n\n\tresponse, err := httpClient.Do(req)\n\tif err != nil {\n\t\tcancel()\n\t\treturn nil, fmt.Errorf(\"error doing HTTP fetch of %q: %v\", url, err)\n\t}\n\n\t// http.Client follows 3xx automatically, so anything outside 2xx that reaches us is a bug or a missing Location.\n\tif response.StatusCode < 200 || response.StatusCode > 299 {\n\t\tresponse.Body.Close()\n\t\tcancel()\n\t\treturn nil, fmt.Errorf(\"unexpected response from %q: HTTP %s\", url, response.Status)\n\t}\n\n\treturn &cancelOnCloseReadCloser{ReadCloser: response.Body, cancel: cancel}, nil\n}\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/http.go#L130-L166","documentation":"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.","triggerScenarios":"Thrown at upup/pkg/fi/http.go:148 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}