wtfutil/wtf · error
failed to parse API URL %s
Error message
failed to parse API URL %s
What it means
Guard in getStatus fired when url.Parse cannot parse the configured apiURL, meaning the Pi-hole API URL string is malformed (bad scheme, invalid characters, etc.). Fetching the Pi-hole status cannot proceed without a valid URL, so the parse error is embedded via parseError and returned; getSummaryView surfaces it in the module. Fix by correcting the apiURL setting (e.g. a proper http://host:port/api endpoint).
Source
Thrown at modules/pihole/client.go:39
QueriesForwarded string `json:"queries_forwarded"`
QueriesCached string `json:"queries_cached"`
Status string `json:"status"`
GravityLastUpdated struct {
Relative struct {
Days FlexInt `json:"days"`
Hours FlexInt `json:"hours"`
Minutes FlexInt `json:"minutes"`
}
} `json:"gravity_last_updated"`
}
func getStatus(c http.Client, apiURL string) (status Status, err error) {
var req *http.Request
var url *url2.URL
if url, err = url2.Parse(apiURL); err != nil {
return status, fmt.Errorf(" failed to parse API URL\n %s", parseError(err))
}
var query url2.Values
if query, err = url2.ParseQuery(url.RawQuery); err != nil {
return status, fmt.Errorf(" failed to parse query\n %s", parseError(err))
}
query.Add("summary", "")
url.RawQuery = query.Encode()
if req, err = http.NewRequest("GET", url.String(), http.NoBody); err != nil {
return status, fmt.Errorf(" failed to create request\n %s", parseError(err))
}
var resp *http.Response
if resp, err = c.Do(req); err != nil || resp == nil {View on GitHub (pinned to bb838c1ccb)
Solutions
- Fix the apiUrl setting so it is a well-formed URL (e.g. http://pi.hole/admin/api.php)
- Check for missing scheme, stray spaces, or unescaped characters in the configured URL
- Test the URL in a browser or with curl before putting it in config
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/pihole/client.go:39 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03).
Data as JSON: /api/errors/40e7024e0e30d57c.
Report an issue: GitHub.