{"record":{"id":"d1b44014d1c61bb3","repo":"chenhg5/cc-connect","slug":"yuanbao-request-failed-w","errorCode":null,"errorMessage":"yuanbao: request failed: %w","messagePattern":"yuanbao: request failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/yuanbao/sign.go","lineNumber":154,"sourceCode":"\t\t}\n\t\tbody, _ := json.Marshal(payload)\n\n\t\treq, err := http.NewRequest(\"POST\", urlStr, strings.NewReader(string(body)))\n\t\tif err != nil {\n\t\t\tlastErr = fmt.Errorf(\"yuanbao: create request: %w\", err)\n\t\t\tcontinue\n\t\t}\n\t\treq.Header.Set(\"Content-Type\", \"application/json\")\n\t\treq.Header.Set(\"X-AppVersion\", \"cc-connect-yuanbao/1.0.0\")\n\t\treq.Header.Set(\"X-Instance-Id\", fmt.Sprintf(\"%d\", instanceID))\n\t\treq.Header.Set(\"X-Bot-Version\", \"cc-connect-yuanbao/1.0.0\")\n\t\tif routeEnv != \"\" {\n\t\t\treq.Header.Set(\"X-Route-Env\", routeEnv)\n\t\t}\n\n\t\tresp, err := client.Do(req)\n\t\tif err != nil {\n\t\t\tlastErr = fmt.Errorf(\"yuanbao: request failed: %w\", err)\n\t\t\tcontinue\n\t\t}\n\t\trespBody, _ := io.ReadAll(resp.Body)\n\t\t_ = resp.Body.Close()\n\t\tif resp.StatusCode != http.StatusOK {\n\t\t\tlastErr = fmt.Errorf(\"yuanbao: sign token API returned %d: %s\", resp.StatusCode, string(respBody))\n\t\t\tcontinue\n\t\t}\n\n\t\tvar result struct {\n\t\t\tCode int `json:\"code\"`\n\t\t\tData *struct {\n\t\t\t\tToken    string `json:\"token\"`\n\t\t\t\tBotID    string `json:\"bot_id\"`\n\t\t\t\tDuration int    `json:\"duration\"`\n\t\t\t\tProduct  string `json:\"product\"`\n\t\t\t\tSource   string `json:\"source\"`\n\t\t\t} `json:\"data\"`","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/yuanbao/sign.go#L136-L172","documentation":"The HTTP client's Do(req) call inside yuanbao's fetchToken returned a transport-level error (DNS failure, connection refused, TLS error, timeout). The error is wrapped as lastErr and the retry loop continues to the next attempt; after all retries the last error is returned. It means the sign-token API endpoint could not be reached at all.","triggerScenarios":"client.Do(req) returns err during any fetchToken attempt — called from getToken at session start or from VerifyCredentials during `cc-connect yuanbao setup`.","commonSituations":"api_domain pointing to a host that is down or wrong (typo in domain), corporate proxy/firewall blocking outbound HTTPS, DNS not resolving the yuanbao endpoint, no internet access from the daemon host.","solutions":["Verify network reachability: `curl -v https://<api_domain>` from the same host to see DNS/TLS/connection errors.","Check the api_domain setting in config.toml for typos or a stale/renamed endpoint.","Check proxy environment variables (HTTP_PROXY/HTTPS_PROXY/NO_PROXY) if the host requires a proxy.","Retry later if the endpoint is temporarily down — fetchToken already retries up to maxRetries internally."],"exampleFix":"// before (verifying config)\napi_domain = \"https://yuanbao-wrong-host.example.com\"\n// after\napi_domain = \"https://yuanbao.example.com\"","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", host+\":443\", 5*time.Second)\nif err != nil { return fmt.Errorf(\"sign-token host unreachable: %w\", err) }\nconn.Close()","typeGuard":null,"tryCatchPattern":"if err := fetchToken(...); err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) { /* schedule retry with backoff */ }\n    slog.Error(\"token fetch failed\", \"err\", err)\n}","preventionTips":["Verify DNS and TLS reachability of api_domain before enabling the platform","Configure proxy env vars if the host needs one","Monitor the endpoint with a periodic health probe"],"tags":["network","http","connectivity","retry"],"backgroundTag":"api-request-failed","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"}