{"record":{"id":"5534876b12b98206","repo":"AlistGo/alist","slug":"doubao-new-api-error-code-d-s","errorCode":null,"errorMessage":"[doubao_new] API error (code: %d): %s","messagePattern":"\\[doubao_new\\] API error \\(code: (.+?)\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/doubao_new/util.go","lineNumber":74,"sourceCode":"\t}\n\n\tbody := res.Body()\n\tvar common BaseResp\n\tif err = json.Unmarshal(body, &common); err != nil {\n\t\tmsg := fmt.Sprintf(\"[doubao_new] decode response failed (status: %s, content-type: %s, body: %s): %v\",\n\t\t\tres.Status(),\n\t\t\tres.Header().Get(\"Content-Type\"),\n\t\t\tstring(body),\n\t\t\terr,\n\t\t)\n\t\treturn body, fmt.Errorf(msg)\n\t}\n\tif common.Code != 0 {\n\t\terrMsg := common.Msg\n\t\tif errMsg == \"\" {\n\t\t\terrMsg = common.Message\n\t\t}\n\t\treturn body, fmt.Errorf(\"[doubao_new] API error (code: %d): %s\", common.Code, errMsg)\n\t}\n\tif resp != nil {\n\t\tif err = json.Unmarshal(body, resp); err != nil {\n\t\t\treturn body, err\n\t\t}\n\t}\n\n\treturn body, nil\n}\n\nfunc getCookieValue(cookie, name string) string {\n\tparts := strings.Split(cookie, \";\")\n\tprefix := name + \"=\"\n\tfor _, part := range parts {\n\t\tpart = strings.TrimSpace(part)\n\t\tif strings.HasPrefix(part, prefix) {\n\t\t\treturn strings.TrimPrefix(part, prefix)\n\t\t}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/doubao_new/util.go#L56-L92","documentation":"Doubao_new business error surfaced by the generic response decoder: the body parsed fine as JSON but BaseResp.Code != 0, meaning the Doubao web API rejected the call. The message prefers Msg then Message fields from the response. This is the canonical 'the server said no' error for every doubao_new operation.","triggerScenarios":"Any doubao_new API call hitting a business failure: expired session cookie (auth code), invalid folder token, quota exceeded, file name not allowed, rate limiting, or operation not permitted for the account state.","commonSituations":"Cookie-based auth going stale (most common — re-login fixes it), uploading to a deleted/moved folder, hitting operation frequency limits during heavy listing/upload, or Doubao A/B testing new endpoints that need updated parameters.","solutions":["Decode the code number: auth/session codes → refresh the driver's cookies; quota codes → free space; rate-limit codes → back off and retry slower","Re-authenticate the doubao driver in OpenList settings and retry","Verify the target path exists and the operation is valid for it","If code is unrecognized and all operations fail, check for an API change and update the driver","Add delays between rapid successive operations to avoid frequency-limit codes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isAuthCodeError(err error) bool {\n    m := regexp.MustCompile(`API error \\(code: (\\d+)\\)`).FindStringSubmatch(err.Error())\n    return m != nil && isDoubaoAuthCode(m[1]) // maintain a small auth-code set\n}","tryCatchPattern":"if err := d.apiCall(...); err != nil {\n    if isAuthCodeError(err) {\n        d.refreshSession() // re-login, then retry once\n        return d.apiCall(...)\n    }\n    if isRateLimitCode(err) {\n        time.Sleep(5 * time.Second)\n        return d.apiCall(...)\n    }\n    return err\n}","preventionTips":["Map known Doubao business codes to actions (auth → re-login, rate-limit → backoff, quota → stop)","Renew cookies proactively before long batch operations","Rate-limit your own listing/upload loops"],"tags":["doubao-new","api-error","auth","rate-limit","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}