{"record":{"id":"82442e92b7b291a2","repo":"glanceapp/glance","slug":"creating-authentication-request-v","errorCode":null,"errorMessage":"creating authentication request: %v","messagePattern":"creating authentication request: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-dns-stats.go","lineNumber":623,"sourceCode":"\t\t\t\tPercentBlocked: int(float64(d.Count) / float64(statsResponse.Queries.Blocked) * 100),\n\t\t\t})\n\t\t}\n\n\t\tsort.Slice(domains, func(a, b int) bool {\n\t\t\treturn domains[a].PercentBlocked > domains[b].PercentBlocked\n\t\t})\n\t\tstats.TopBlockedDomains = domains[:min(len(domains), 5)]\n\t}\n\n\treturn stats, sessionID, ternary(partialContent, errPartialContent, nil)\n}\n\nfunc fetchPiholeSessionID(instanceURL string, client *http.Client, password string) (string, error) {\n\trequestBody := []byte(`{\"password\":\"` + password + `\"}`)\n\n\trequest, err := http.NewRequest(\"POST\", instanceURL+\"/api/auth\", bytes.NewBuffer(requestBody))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"creating authentication request: %v\", err)\n\t}\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"sending authentication request: %v\", err)\n\t}\n\tdefer response.Body.Close()\n\n\tbody, err := io.ReadAll(response.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"reading authentication response: %v\", err)\n\t}\n\n\tvar jsonResponse struct {\n\t\tSession struct {\n\t\t\tSID     string `json:\"sid\"`\n\t\t\tMessage string `json:\"message\"`","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-dns-stats.go#L605-L641","documentation":"Returned by fetchPiholeSessionID when http.NewRequest(\"POST\", instanceURL+\"/api/auth\", ...) fails before any network I/O. NewRequest fails only on an unparseable URL: unsupported scheme, control characters in the URL, or a malformed host — so this almost always means the configured URL string itself is broken.","triggerScenarios":"url containing spaces or control characters, a scheme like ftp:// or missing entirely (no http://), or a password/URL concatenation producing invalid characters in the request line.","commonSituations":"YAML value with a trailing space or unquoted special characters; copy-pasted URL missing the scheme; environment-variable-substituted URL that rendered empty or malformed.","solutions":["Inspect the widget's url value for typos, missing scheme, spaces, or bad interpolation.","Always include the scheme: http://pihole.local or https://...","Quote the URL in YAML if it contains special characters.","Test with url.Parse in Go or simply curl the same string."],"exampleFix":"# before\nurl: pihole.local:80\n\n# after\nurl: http://pihole.local:80","handlingStrategy":"validation","validationCode":"u, err := url.Parse(widget.URL)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") || u.Host == \"\" {\n    return fmt.Errorf(\"dns-stats: url must be a valid http(s) URL, got %q\", widget.URL)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always configure full URLs with scheme (http:// or https://).","Quote YAML URL values containing special characters.","Fail config validation on empty/scheme-less URLs before runtime."],"tags":["config","url","pihole","dns-stats"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}