{"record":{"id":"3401c41970d1d401","repo":"chenhg5/cc-connect","slug":"yuanbao-sign-token-error-code-d","errorCode":null,"errorMessage":"yuanbao: sign token error code=%d","messagePattern":"yuanbao: sign token error code=(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/yuanbao/sign.go","lineNumber":182,"sourceCode":"\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\"`\n\t\t}\n\t\tif err := json.Unmarshal(respBody, &result); err != nil {\n\t\t\tlastErr = fmt.Errorf(\"yuanbao: parse response: %w\", err)\n\t\t\tcontinue\n\t\t}\n\t\tif result.Code == 10099 && attempt < maxRetries {\n\t\t\tcontinue\n\t\t}\n\t\tif result.Code != 0 {\n\t\t\treturn nil, fmt.Errorf(\"yuanbao: sign token error code=%d\", result.Code)\n\t\t}\n\t\tif result.Data == nil {\n\t\t\treturn nil, fmt.Errorf(\"yuanbao: sign token response missing data\")\n\t\t}\n\t\treturn &tokenData{\n\t\t\ttoken: result.Data.Token, botID: result.Data.BotID,\n\t\t\tduration: result.Data.Duration, product: result.Data.Product,\n\t\t\tsource: result.Data.Source,\n\t\t}, nil\n\t}\n\treturn nil, lastErr\n}\n\n// VerifyCredentials probes the sign-token API with app_key/app_secret and\n// returns the bot_id on success. Used by `cc-connect yuanbao setup` so users\n// see a clear error before the platform starts retrying on a background loop.\nfunc VerifyCredentials(appKey, appSecret, apiDomain, routeEnv string) (botID string, err error) {\n\tif strings.TrimSpace(appKey) == \"\" || strings.TrimSpace(appSecret) == \"\" {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/yuanbao/sign.go#L164-L200","documentation":"The sign-token API returned a parseable envelope whose business code was not 0 (and not the retryable 10099 within the retry budget). fetchToken returns this error immediately — unlike transport errors, business-code failures are not retried. The numeric code is the upstream service's own error identifier.","triggerScenarios":"result.Code != 0 after a successful 200 response during fetchToken — e.g. invalid credentials, expired/revoked app_key, account quota exceeded, or code 10099 persisting after maxRetries attempts.","commonSituations":"Rotated or mistyped app_secret in bot_token, account disabled on the yuanbao side, persistent 10099 (throttling/auth-challenge) that outlives the retry budget.","solutions":["Map the code value to the yuanbao API's documented error table to identify the business failure.","Re-verify bot_token credentials with `cc-connect yuanbao setup`; regenerate app_key/app_secret if revoked.","If the code is 10099 repeatedly, the service is throttling/challenging — wait longer between attempts or check account status.","Fix the config value and restart the daemon; this error is terminal for the token fetch."],"exampleFix":"// before\nbot_token = \"old_app_key:old_secret\"\n// after\nbot_token = \"new_app_key:new_secret\"","handlingStrategy":"try-catch","validationCode":"botID, err := VerifyCredentials(appKey, appSecret, apiDomain, routeEnv)\nif err != nil { failFast(\"yuanbao credentials invalid: \" + err.Error()) }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"sign token error code=\") {\n    code := parseCode(err)\n    switch code {\n    case 10099: backoffAndRetry()\n    default: alertAndStop()\n    }\n}","preventionTips":["Validate credentials at startup with `cc-connect yuanbao setup`, not lazily in background loops","Keep a documented mapping of upstream business codes","Alert on non-zero codes instead of hot-looping retries"],"tags":["api","authentication","business-error","upstream"],"backgroundTag":"api-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}