{"record":{"id":"46351aa84252ca49","repo":"wtfutil/wtf","slug":"failed-to-create-request-s","errorCode":null,"errorMessage":" failed to create request\n %s","messagePattern":" failed to create request\n (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/pihole/client.go","lineNumber":52,"sourceCode":"\tvar req *http.Request\n\n\tvar url *url2.URL\n\n\tif url, err = url2.Parse(apiURL); err != nil {\n\t\treturn status, fmt.Errorf(\" failed to parse API URL\\n %s\", parseError(err))\n\t}\n\n\tvar query url2.Values\n\n\tif query, err = url2.ParseQuery(url.RawQuery); err != nil {\n\t\treturn status, fmt.Errorf(\" failed to parse query\\n %s\", parseError(err))\n\t}\n\n\tquery.Add(\"summary\", \"\")\n\n\turl.RawQuery = query.Encode()\n\tif req, err = http.NewRequest(\"GET\", url.String(), http.NoBody); err != nil {\n\t\treturn status, fmt.Errorf(\" failed to create request\\n %s\", parseError(err))\n\t}\n\n\tvar resp *http.Response\n\n\tif resp, err = c.Do(req); err != nil || resp == nil {\n\t\treturn status, fmt.Errorf(\" failed to connect to Pi-hole server\\n %s\", parseError(err))\n\t}\n\n\tdefer func() {\n\t\tif closeErr := resp.Body.Close(); closeErr != nil {\n\t\t\treturn\n\t\t}\n\t}()\n\n\tif resp.StatusCode >= http.StatusBadRequest {\n\t\treturn status, fmt.Errorf(\" failed to retrieve version from Pi-hole server\\n http status code: %d\",\n\t\t\tresp.StatusCode)\n\t}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/pihole/client.go#L34-L70","documentation":"Raised in getStatus when http.NewRequest fails to construct the GET request for the Pi-hole summary API — a programming-level or URL-construction failure (e.g. invalid URL produced after query encoding), not a network problem.","triggerScenarios":"Thrown at modules/pihole/client.go:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the final URL (parsed URL plus encoded query) is a valid absolute HTTP(S) URL","Check the configured apiUrl does not contain characters that survive parsing but break request construction","Update the module if this occurs with a known-good URL — it may be a client bug"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}