{"record":{"id":"55110da3e24df238","repo":"chenhg5/cc-connect","slug":"weibo-token-request-w","errorCode":null,"errorMessage":"weibo: token request: %w","messagePattern":"weibo: token request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/weibo/weibo.go","lineNumber":167,"sourceCode":"\nfunc (p *Platform) refreshToken() (string, error) {\n\tp.tokenMu.Lock()\n\tdefer p.tokenMu.Unlock()\n\n\tif p.token != \"\" && time.Now().Before(p.tokenExpiry.Add(-tokenRenewBuf)) {\n\t\treturn p.token, nil\n\t}\n\n\tbody := fmt.Sprintf(`{\"app_id\":\"%s\",\"app_secret\":\"%s\"}`, p.appID, p.appSecret)\n\treq, err := http.NewRequest(\"POST\", p.tokenEndpoint, strings.NewReader(body))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"weibo: build token request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"weibo: token request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\traw, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"weibo: read token response: %w\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"weibo: token HTTP %d: %s\", resp.StatusCode, string(raw))\n\t}\n\n\tvar tr tokenResponse\n\tif err := json.Unmarshal(raw, &tr); err != nil {\n\t\treturn \"\", fmt.Errorf(\"weibo: parse token response: %w\", err)\n\t}\n\tif tr.Data.Token == \"\" {\n\t\treturn \"\", fmt.Errorf(\"weibo: empty token in response: %s\", string(raw))","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/weibo/weibo.go#L149-L185","documentation":"Transport-level failure of the token-refresh POST to token_endpoint: http.DefaultClient.Do could not complete the request — DNS resolution failure, connection refused/reset, TLS handshake error, or timeout. The credentials were never evaluated; nothing was received from the server.","triggerScenarios":"Thrown at platform/weibo/weibo.go:167 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the refresh with backoff; the existing token (if any) keeps serving until expiry minus tokenRenewBuf","Check network/proxy/firewall access to the token endpoint host","Use a configured http.Client with sane timeouts instead of DefaultClient for hard guarantees"],"exampleFix":null,"handlingStrategy":"retry","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-14T05:17:10.506Z"}