glanceapp/glance · error
creating request for app access token: %v
Error message
creating request for app access token: %v
What it means
http.NewRequest failed while constructing the POST to https://www.reddit.com/api/v1/access_token. The URL is a constant and valid, so with a non-nil body reader this error is effectively unreachable in practice; seeing it indicates memory corruption or an exotic runtime condition rather than a config problem.
Source
Thrown at internal/glance/widget-reddit.go:301
forumPost.TargetUrl = widget.parseCustomCommentsURL(
post.ParentList[0].Subreddit,
post.ParentList[0].Id,
post.ParentList[0].Permalink,
)
}
}
posts = append(posts, forumPost)
}
return posts, nil
}
func (widget *redditWidget) fetchNewAppAccessToken() error {
body := strings.NewReader("grant_type=client_credentials")
req, err := http.NewRequest("POST", "https://www.reddit.com/api/v1/access_token", body)
if err != nil {
return fmt.Errorf("creating request for app access token: %v", err)
}
app := &widget.AppAuth
req.SetBasicAuth(app.ID, app.Secret)
req.Header.Add("User-Agent", app.Name+"/1.0")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
type tokenResponse struct {
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
}
client := ternary(widget.Proxy.client != nil, widget.Proxy.client, defaultHTTPClient)
response, err := decodeJsonFromRequest[tokenResponse](client, req)
if err != nil {
return err
}
View on GitHub (pinned to 91324e8de7)
Solutions
- Treat as a bug — report it upstream with the wrapped error text
- Verify the glance binary is not corrupted (rebuild/re-pull the image)
Defensive patterns
Strategy: try-catch
Try / catch
if err := widget.fetchNewAppAccessToken(); err != nil {
slog.Error("unexpected reddit token request failure", "error", err)
return err // report upstream — this path should be unreachable
} Prevention
- No user action prevents it; keep glance updated so any real occurrence is fixed upstream
When it happens
Trigger: Practically none — the fixed URL always parses and strings.NewReader never fails. Would only occur if the hardcoded URL were modified to something invalid.
Common situations: Not seen in practice; mentioned only for completeness of the error surface.
Related errors
- invalid include match: %v
- subreddit is required
- no `{REQUEST-URL}` placeholder specified
- application name, client ID and client secret are required
- could not solve reddit challenge
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/0e81876ba09dc3cc.
Report an issue: GitHub.