{"record":{"id":"04e7da4950ab7e1e","repo":"chenhg5/cc-connect","slug":"s-w-04e7da","errorCode":null,"errorMessage":"%s: %w","messagePattern":"%s: %w","errorType":"http","errorClass":"errUnauthorized","httpStatus":401,"severity":"error","filePath":"platform/webex/client.go","lineNumber":82,"sourceCode":"\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+c.token)\n\tif contentType != \"\" {\n\t\treq.Header.Set(\"Content-Type\", contentType)\n\t}\n\treturn c.hc.Do(req)\n}\n\n// doWithRetry wraps do to surface 401 as errUnauthorized and to retry once on\n// 429 after honoring the Retry-After header (capped). The returned response (on\n// success) has an unread body the caller must close.\nfunc (c *httpClient) doWithRetry(ctx context.Context, method, url string, body []byte, contentType, what string) (*http.Response, error) {\n\tresp, err := c.do(ctx, method, url, body, contentType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode == http.StatusUnauthorized {\n\t\t_ = resp.Body.Close()\n\t\treturn nil, fmt.Errorf(\"%s: %w\", what, errUnauthorized)\n\t}\n\tif resp.StatusCode == http.StatusTooManyRequests {\n\t\twait := retryAfter(resp.Header.Get(\"Retry-After\"))\n\t\t_ = resp.Body.Close()\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil, ctx.Err()\n\t\tcase <-time.After(wait):\n\t\t}\n\t\tresp, err = c.do(ctx, method, url, body, contentType)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif resp.StatusCode == http.StatusUnauthorized {\n\t\t\t_ = resp.Body.Close()\n\t\t\treturn nil, fmt.Errorf(\"%s: %w\", what, errUnauthorized)\n\t\t}\n\t}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/webex/client.go#L64-L100","documentation":"webex httpClient.doWithRetry wraps the transport error from do() for every Webex REST call (GetMe, CreateDevice, DeleteDevice, GetMessage, DownloadFile, PostMessage); the 'what' label names the operation. 401 (errUnauthorized) and 429 (Retry-After) handling happen only after this wrapper returns a response.","triggerScenarios":"Thrown at platform/webex/client.go:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network/proxy reachability of Webex APIs and retry transient errors","A 401 is surfaced as errUnauthorized for token refresh upstream"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}