chenhg5/cc-connect · error
yuanbao: sign token API returned %d: %s
Error message
yuanbao: sign token API returned %d: %s
What it means
The yuanbao sign-token API responded with an HTTP status other than 200. fetchToken records the status code plus the raw response body in the error and retries; after the retry budget is exhausted the last error is returned to the caller. The embedded body snippet is the server's own explanation.
Source
Thrown at platform/yuanbao/sign.go:160
continue
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-AppVersion", "cc-connect-yuanbao/1.0.0")
req.Header.Set("X-Instance-Id", fmt.Sprintf("%d", instanceID))
req.Header.Set("X-Bot-Version", "cc-connect-yuanbao/1.0.0")
if routeEnv != "" {
req.Header.Set("X-Route-Env", routeEnv)
}
resp, err := client.Do(req)
if err != nil {
lastErr = fmt.Errorf("yuanbao: request failed: %w", err)
continue
}
respBody, _ := io.ReadAll(resp.Body)
_ = resp.Body.Close()
if resp.StatusCode != http.StatusOK {
lastErr = fmt.Errorf("yuanbao: sign token API returned %d: %s", resp.StatusCode, string(respBody))
continue
}
var result struct {
Code int `json:"code"`
Data *struct {
Token string `json:"token"`
BotID string `json:"bot_id"`
Duration int `json:"duration"`
Product string `json:"product"`
Source string `json:"source"`
} `json:"data"`
}
if err := json.Unmarshal(respBody, &result); err != nil {
lastErr = fmt.Errorf("yuanbao: parse response: %w", err)
continue
}
if result.Code == 10099 && attempt < maxRetries {View on GitHub (pinned to 4000b2338a)
Solutions
- Read the body snippet in the error message — it contains the server's status-specific reason.
- If 401/403: re-check bot_token (app_key:app_secret) in config.toml and regenerate credentials if revoked.
- If 429: back off and retry later; reduce how often tokens are refreshed.
- If 5xx: verify the yuanbao service status; the internal retry loop may already absorb transient failures.
Defensive patterns
Strategy: try-catch
Try / catch
data, err := VerifyCredentials(key, secret, domain, route)
if err != nil {
var httpErr *HTTPStatusError
if errors.As(err, &httpErr) && httpErr.Code == 429 {
time.Sleep(backoff); retry()
}
} Prevention
- Keep bot_token credentials current; rotate before expiry
- Respect 429 responses with exponential backoff
- Watch upstream status pages for 5xx incidents
When it happens
Trigger: Any fetchToken attempt (via getToken or VerifyCredentials) where resp.StatusCode != http.StatusOK — e.g. 401 from bad app_key/app_secret, 403 from IP allowlist, 429 rate limit, 5xx server outage.
Common situations: Wrong or revoked app_secret in bot_token, calling an incorrect api_domain that answers 404, the sign service rate-limiting retries, server-side incident returning 500/502.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- whisper API %d: %s
- yuanbao: sign token error code=%d
- usage endpoint returned status %d: %s
- reasonix: POST %s returned %d: %s
- gitee API returned HTTP %d
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/bb8d54160f2dadba.
Report an issue: GitHub.