{"record":{"id":"2d0f33b55b5ea522","repo":"AlistGo/alist","slug":"list-offline-tasks-failed-s","errorCode":null,"errorMessage":"list offline tasks failed: %s","messagePattern":"list offline tasks failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/guangyapan/offline.go","lineNumber":109,"sourceCode":"\tif len(taskIDs) > 0 {\n\t\tbody[\"taskIds\"] = taskIDs\n\t}\n\tif len(statuses) > 0 {\n\t\tbody[\"status\"] = statuses\n\t}\n\tif cursor = strings.TrimSpace(cursor); cursor != \"\" {\n\t\tbody[\"cursor\"] = cursor\n\t}\n\tif pageSize > 0 {\n\t\tbody[\"pageSize\"] = pageSize\n\t}\n\n\tvar resp offlineListResp\n\tif err := d.postAPI(ctx, \"/cloudcollection/v1/list_task\", body, &resp); err != nil {\n\t\treturn nil, err\n\t}\n\tif !isSuccessMsg(resp.Msg) {\n\t\treturn nil, fmt.Errorf(\"list offline tasks failed: %s\", strings.TrimSpace(resp.Msg))\n\t}\n\treturn resp.Data.List, nil\n}\n\nfunc (d *GuangYaPan) DeleteOfflineTasks(ctx context.Context, taskIDs []string, deleteFiles bool) error {\n\tif err := d.ensureAccessToken(ctx); err != nil {\n\t\treturn err\n\t}\n\tif len(taskIDs) == 0 {\n\t\treturn nil\n\t}\n\n\tvar resp offlineDeleteResp\n\tif err := d.postAPI(ctx, \"/cloudcollection/v2/delete_task\", map[string]any{\n\t\t\"taskIds\": taskIDs,\n\t}, &resp); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/guangyapan/offline.go#L91-L127","documentation":"Thrown by GuangYaPan's ListOfflineTasks after the cloud-collection list API (POST /cloudcollection/v1/list_task) returns HTTP 200 but a Msg field that is not a success marker. The HTTP transport succeeded, so the failure is at the application/protocol level: the server rejected the listing request. The raw server message is embedded via %s after trimming whitespace.","triggerScenarios":"Calling ListOfflineTasks with a cursor from an expired/invalid pagination session, a pageSize the backend rejects, an access token that was valid at ensureAccessToken time but revoked before the call, or when the account has no offline-download permission on the cloudcollection endpoint.","commonSituations":"Stale cursor reused after a long pagination walk; token invalidated by logging in on another device; the guangyapan offline API changed its response contract between app versions; rate limiting reported as a non-success msg.","solutions":["Read the embedded resp.Msg — it is the server's own reason and disambiguates auth vs. param vs. rate-limit failures.","Re-run ensureAccessToken (or re-login) and retry the list once from the first page with an empty cursor.","Validate cursor/pageSize inputs: send pageSize only when > 0 and only pass cursors returned by a previous response.","If msg indicates permission denial, enable/verify the offline-download feature for the account before retrying."],"exampleFix":"// before\nlist, err := d.ListOfflineTasks(ctx, staleCursor, 0)\nif err != nil { return err }\n\n// after\nlist, err := d.ListOfflineTasks(ctx, \"\", 100) // restart from first page\nif err != nil {\n    if strings.Contains(err.Error(), \"login\") { // heuristic on server msg\n        if rerr := d.ensureAccessToken(ctx); rerr != nil { return rerr }\n        list, err = d.ListOfflineTasks(ctx, \"\", 100)\n    }\n    if err != nil { return err }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := d.ListOfflineTasks(ctx, cursor, size); err != nil {\n    if strings.Contains(err.Error(), \"list offline tasks failed\") {\n        // one retry from first page with fresh token\n        _ = d.ensureAccessToken(ctx)\n        _, err = d.ListOfflineTasks(ctx, \"\", size)\n    }\n    if err != nil { return err }\n}","preventionTips":["Only pass cursors obtained from the immediately previous response","Re-verify the access token before long pagination walks","Cap pageSize to provider-documented limits"],"tags":["guangyapan","offline-download","api-error","pagination"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}