glanceapp/glance · error
reading authentication response: %v
Error message
reading authentication response: %v
What it means
Returned by fetchPiholeSessionID when io.ReadAll(response.Body) fails while reading the auth response body. Rare: the request succeeded and headers were received, but the stream aborted mid-body — connection reset during transfer, premature close, or a read timeout.
Source
Thrown at internal/glance/widget-dns-stats.go:635
func fetchPiholeSessionID(instanceURL string, client *http.Client, password string) (string, error) {
requestBody := []byte(`{"password":"` + password + `"}`)
request, err := http.NewRequest("POST", instanceURL+"/api/auth", bytes.NewBuffer(requestBody))
if err != nil {
return "", fmt.Errorf("creating authentication request: %v", err)
}
request.Header.Set("Content-Type", "application/json")
response, err := client.Do(request)
if err != nil {
return "", fmt.Errorf("sending authentication request: %v", err)
}
defer response.Body.Close()
body, err := io.ReadAll(response.Body)
if err != nil {
return "", fmt.Errorf("reading authentication response: %v", err)
}
var jsonResponse struct {
Session struct {
SID string `json:"sid"`
Message string `json:"message"`
} `json:"session"`
}
if err := json.Unmarshal(body, &jsonResponse); err != nil {
return "", fmt.Errorf("parsing authentication response: %v", err)
}
if response.StatusCode != http.StatusOK {
return "", fmt.Errorf(
"authentication request returned status %s with message '%s'",
response.Status, jsonResponse.Session.Message,
)View on GitHub (pinned to 91324e8de7)
Solutions
- Retry — transient mid-body failures usually clear on the next widget refresh.
- If persistent, capture whether a proxy between glance and Pi-hole truncates responses.
- Increase client timeouts if the Pi-hole host is slow (high load).
- Verify with a large curl of the same endpoint that the body transfers fully.
Defensive patterns
Strategy: retry
Try / catch
if err != nil && strings.Contains(err.Error(), "reading authentication response") {
// mid-body abort: almost always transient — rely on the next refresh
slog.Warn("pihole auth body read failed, will retry", "error", err)
} Prevention
- Treat mid-body read failures as transient; do not reconfigure on a single occurrence.
- Stabilize flaky links/VPNs between glance and the Pi-hole host.
- Ensure proxies do not truncate responses (check Content-Length vs delivered bytes).
When it happens
Trigger: Upstream or an intermediary proxy closes the connection before Content-Length bytes arrive; client read timeout shorter than the server's response time; connection reset by a firewall or load balancer.
Common situations: Flaky Wi-Fi/VPN link to a self-hosted Pi-hole; aggressive proxy idle timeouts; Pi-hole restarting exactly while responding.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- fetching session ID: %v
- checking session ID: %v
- renewing session ID: %v
- fetching stats: %v
- sending authentication request: %v
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/7802ddc8a08b4764.
Report an issue: GitHub.