{"record":{"id":"3d5a66e3e7c3bcc6","repo":"chenhg5/cc-connect","slug":"weibo-parse-token-response-w","errorCode":null,"errorMessage":"weibo: parse token response: %w","messagePattern":"weibo: parse token response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/weibo/weibo.go","lineNumber":182,"sourceCode":"\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))\n\t}\n\n\tp.token = tr.Data.Token\n\tp.tokenExpiry = time.Now().Add(time.Duration(tr.Data.ExpireIn) * time.Second)\n\tif len(tr.Data.UID) > 0 {\n\t\tp.uid = strings.Trim(string(tr.Data.UID), `\"`)\n\t}\n\n\tslog.Debug(p.tag()+\": token refreshed\", \"expires_in\", tr.Data.ExpireIn)\n\treturn p.token, nil\n}\n\nfunc (p *Platform) getToken() (string, error) {\n\tp.tokenMu.Lock()\n\ttok := p.token","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/weibo/weibo.go#L164-L200","documentation":"The Weibo OAuth token endpoint returned HTTP 200 but its body is not valid JSON matching the tokenResponse struct (e.g. an HTML login page, empty body, or a schema change), so json.Unmarshal failed while refreshing the platform access token in refreshToken.","triggerScenarios":"Thrown at platform/weibo/weibo.go:182 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the raw response body (truncated/redacted) alongside the unmarshal error to see what the endpoint actually returned","Check that the configured Weibo app credentials (app_id/secret) are correct, since an auth failure can return a non-JSON error page with 200","Verify the tokenResponse struct still matches the current Weibo API schema"],"exampleFix":null,"handlingStrategy":"fallback","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"}