{"record":{"id":"c1ea1a8d8ec691cc","repo":"AlistGo/alist","slug":"baidu-youth-s-errno-d","errorCode":null,"errorMessage":"[baidu_youth] %s (errno=%d)","messagePattern":"\\[baidu_youth\\] (.+?) \\(errno=(.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/baidu_youth/util.go","lineNumber":113,"sourceCode":"\t\tcallback(req)\n\t}\n\tif resp != nil {\n\t\treq.SetResult(resp)\n\t}\n\tres, err := req.Execute(method, d.normalizeURL(furl))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbody := res.Body()\n\tif errno := utils.Json.Get(body, \"errno\").ToInt(); errno != 0 {\n\t\tmsg := extractBaiduMessage(body)\n\t\tif errno == -6 && msg == \"\" {\n\t\t\tmsg = \"cookie expired or invalid\"\n\t\t}\n\t\tif msg == \"\" {\n\t\t\tmsg = \"request failed\"\n\t\t}\n\t\treturn nil, fmt.Errorf(\"[baidu_youth] %s (errno=%d)\", msg, errno)\n\t}\n\treturn body, nil\n}\n\nfunc (d *BaiduYouth) get(ctx context.Context, pathname string, params map[string]string, resp interface{}) ([]byte, error) {\n\treturn d.doRequest(pathname, http.MethodGet, youthQueryParams(), func(req *resty.Request) {\n\t\treq.SetContext(ctx)\n\t\tif params != nil {\n\t\t\treq.SetQueryParams(params)\n\t\t}\n\t}, resp)\n}\n\nfunc (d *BaiduYouth) postForm(ctx context.Context, pathname string, params map[string]string, form map[string]string, resp interface{}) ([]byte, error) {\n\treturn d.doRequest(pathname, http.MethodPost, youthQueryParams(), func(req *resty.Request) {\n\t\treq.SetContext(ctx)\n\t\tif params != nil {\n\t\t\treq.SetQueryParams(params)","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/baidu_youth/util.go#L95-L131","documentation":"Catch-all in BaiduYouth.doRequest (drivers/baidu_youth/util.go:113): the endpoint returned JSON with a non-zero errno, and the driver wraps the best available message as '[baidu_youth] %s (errno=%d)'. The message is extracted from the response body (extractBaiduMessage); errno -6 specifically maps to 'cookie expired or invalid' when no message is present.","triggerScenarios":"Any BaiduYouth get/post with failing errno: expired BDUSS/SToken cookie (-6), invalid signature on locatedownload (wrong sk or time), removed file, or rate limiting.","commonSituations":"Cookie pasted into config has expired (Baidu rotates sessions); server clock skew breaking time-based signatures; file deleted between list and link.","solutions":["For errno=-6, update the BDUSS/SToken cookies in the storage config and re-init","Check the numeric errno against Baidu docs and the extracted message for the specific endpoint","Verify server clock accuracy (NTP) since several calls sign with current time","Retry once after re-init for transient errnos"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isBaiduYouthErrno(err error) (int, bool) {\n    var target errnoError\n    if errors.As(err, &target) {\n        return target.code, true\n    }\n    // string fallback for the wrapped fmt.Errorf\n    var code int\n    if n, _ := fmt.Sscanf(err.Error(), \"[baidu_youth] %*s (errno=%d)\", &code); n == 1 {\n        return code, true\n    }\n    return 0, false\n}","tryCatchPattern":"body, err := d.get(ctx, path, params, &resp)\nif err != nil {\n    if code, ok := isBaiduYouthErrno(err); ok && code == -6 {\n        // cookie expired: operator must refresh BDUSS/SToken in config\n        return fmt.Errorf(\"baidu_youth cookie expired: update storage credentials: %w\", err)\n    }\n    return err\n}","preventionTips":["Rotate Baidu cookies before they expire; -6 is the dominant failure mode","Keep server time NTP-synced (time participates in request signing)","Log the errno and extracted message together for fast triage"],"tags":["baidu-youth","api","errno","auth"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}