{"record":{"id":"751faf8f47c12ec6","repo":"AlistGo/alist","slug":"doubao-new-decode-response-failed-status-s-c","errorCode":null,"errorMessage":"[doubao_new] decode response failed (status: %s, content-type: %s, body: %s): %v","messagePattern":"\\[doubao_new\\] decode response failed \\(status: (.+?), content-type: (.+?), body: (.+?)\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/doubao_new/util.go","lineNumber":67,"sourceCode":"\t}\n\tif res != nil {\n\t\tif v := res.Header().Get(\"X-Tt-Logid\"); v != \"\" {\n\t\t\td.TtLogid = v\n\t\t} else if v := res.Header().Get(\"x-tt-logid\"); v != \"\" {\n\t\t\td.TtLogid = v\n\t\t}\n\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 {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/doubao_new/util.go#L49-L85","documentation":"Doubao_new response decoding failure in the generic request helper (util.go:67): the HTTP body could not be unmarshaled into the BaseResp envelope. The message helpfully embeds status, content-type, and the full body, so the cause is usually visible in the error text itself (HTML error page, empty body, truncated JSON).","triggerScenarios":"Any API call whose response is not JSON: gateway returning an HTML 4xx/5xx page, WAF challenge/redirect page, empty body from a 502, gzipped body not decoded, or a JSON body truncated by a proxy timeout.","commonSituations":"Cloudflare/edge protection injecting challenge pages when the session cookie expires, reverse proxy buffering limits truncating large listings, rate-limit pages, or API host changes returning HTML redirects to a login page.","solutions":["Read the embedded body snippet in the error message — it identifies the exact page (login redirect, 502, challenge, rate-limit)","If it's an auth/login page: re-authenticate the doubao_new driver (cookies expired)","If it's a proxy error page: fix upstream connectivity or proxy config for the API host","If body is empty with 5xx: retry with backoff, the API node is unhealthy","If a truncated JSON: check proxy response buffering and timeouts on large responses"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// cheap pre-check: sniff content-type before unmarshal\nct := res.Header().Get(\"Content-Type\")\nif !strings.Contains(ct, \"json\") {\n    return body, fmt.Errorf(\"non-JSON response (status %s, ct %s): %s\", res.Status(), ct, truncate(body, 512))\n}","typeGuard":"func isJSONBody(res *resty.Response) bool {\n    ct := res.Header().Get(\"Content-Type\")\n    return strings.Contains(ct, \"json\") || bytes.HasPrefix(bytes.TrimSpace(res.Body()), []byte(\"{\"))\n}","tryCatchPattern":"if err := json.Unmarshal(body, &common); err != nil {\n    if !isJSONBody(res) {\n        // auth challenge / proxy page: refresh session, not a decode bug\n        return body, fmt.Errorf(\"non-JSON response (%s): re-auth likely required\", res.Status())\n    }\n    return body, err\n}","preventionTips":["Always log status+content-type+body snippet on decode failures (the driver does — keep it)","Refresh cookies when HTML challenge pages start appearing","Check proxy buffering limits for large JSON listings"],"tags":["doubao-new","json","decode","http","api-error","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}