{"record":{"id":"0e81876ba09dc3cc","repo":"glanceapp/glance","slug":"creating-request-for-app-access-token-v","errorCode":null,"errorMessage":"creating request for app access token: %v","messagePattern":"creating request for app access token: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-reddit.go","lineNumber":301,"sourceCode":"\t\t\t\tforumPost.TargetUrl = widget.parseCustomCommentsURL(\n\t\t\t\t\tpost.ParentList[0].Subreddit,\n\t\t\t\t\tpost.ParentList[0].Id,\n\t\t\t\t\tpost.ParentList[0].Permalink,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tposts = append(posts, forumPost)\n\t}\n\n\treturn posts, nil\n}\n\nfunc (widget *redditWidget) fetchNewAppAccessToken() error {\n\tbody := strings.NewReader(\"grant_type=client_credentials\")\n\treq, err := http.NewRequest(\"POST\", \"https://www.reddit.com/api/v1/access_token\", body)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating request for app access token: %v\", err)\n\t}\n\n\tapp := &widget.AppAuth\n\treq.SetBasicAuth(app.ID, app.Secret)\n\treq.Header.Add(\"User-Agent\", app.Name+\"/1.0\")\n\treq.Header.Add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\ttype tokenResponse struct {\n\t\tAccessToken string `json:\"access_token\"`\n\t\tExpiresIn   int    `json:\"expires_in\"`\n\t}\n\n\tclient := ternary(widget.Proxy.client != nil, widget.Proxy.client, defaultHTTPClient)\n\tresponse, err := decodeJsonFromRequest[tokenResponse](client, req)\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-reddit.go#L283-L319","documentation":"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.","triggerScenarios":"Practically none — the fixed URL always parses and strings.NewReader never fails. Would only occur if the hardcoded URL were modified to something invalid.","commonSituations":"Not seen in practice; mentioned only for completeness of the error surface.","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)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := widget.fetchNewAppAccessToken(); err != nil {\n    slog.Error(\"unexpected reddit token request failure\", \"error\", err)\n    return err // report upstream — this path should be unreachable\n}","preventionTips":["No user action prevents it; keep glance updated so any real occurrence is fixed upstream"],"tags":["reddit","unreachable","internal"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}