{"record":{"id":"d4f8e793b75baa15","repo":"pot-app/pot-desktop","slug":"get-file-list-error-json-stringify-result","errorCode":null,"errorMessage":"Get File List Error: ${JSON.stringify(result)}","messagePattern":"Get File List Error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/window/Config/pages/Backup/utils/aliyun.jsx","lineNumber":51,"sourceCode":"        method: 'POST',\n        headers: {\n            Authorization: `Bearer ${token}`,\n        },\n        body: Body.json({\n            drive_id,\n            parent_file_id: dir_id,\n            type: 'file',\n            order_by: 'name',\n        }),\n    });\n    if (res.ok) {\n        const result = res.data;\n        if (result['items']) {\n            return result['items'].map((item) => {\n                return item['name'];\n            });\n        } else {\n            throw new Error(`Get File List Error: ${JSON.stringify(result)}`);\n        }\n    } else {\n        const result = res.data;\n        if (result['message']) {\n            throw new Error(result['message']);\n        } else {\n            throw new Error(`Get accessToken Error: ${JSON.stringify(result)}`);\n        }\n    }\n}\n\nexport async function get(token, name) {\n    const drive_id = await driveId(token);\n    const file_id = await getFileByPath(token, drive_id, name);\n    const url = await getDownloadUrl(token, drive_id, file_id);\n    await invoke('aliyun', { operate: 'get', path: '', url });\n}\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/pot-app/pot-desktop/blob/594d32ede96acd106b0256deaa8bb440ffcdff40/src/window/Config/pages/Backup/utils/aliyun.jsx#L33-L69","documentation":"The aliyun (Aliyun Drive / alipan) backup `list` function throws this when the openFile/list API returns HTTP 2xx but the JSON body lacks an `items` field, meaning the response shape is not what the code expects. It dumps the whole response body so the developer can inspect what actually came back.","triggerScenarios":"Calling list(token) where the POST to https://openapi.alipan.com/adrive/v1.0/openFile/list succeeds (res.ok) but the body contains e.g. `{code: 'InvalidParameter', ...}` with no `items` array — typically a drive_id or parent_file_id problem, or an API schema change.","commonSituations":"The access token is valid enough for 2xx but scoped to a different drive, the pot-app folder id is stale, or alipan changed the list response schema (e.g. items renamed or errors now returned with 200 status).","solutions":["Inspect the JSON in the message — the `code` field reveals the API-level error (e.g. InvalidParameter, NotFound.FileId).","Re-authenticate to get a fresh token, then retry — a stale drive_id from an old token is the most common cause.","Verify the drive_id returned by getDriveInfo matches the drive containing the pot-app folder.","If the response schema changed, update the check to handle the new field names."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function hasItems(result) {\n  return result != null && typeof result === 'object' && Array.isArray(result.items);\n}\n// after fetch, before mapping:\nif (res.ok && !hasItems(res.data)) {\n  // handle unexpected schema / embedded error before .map\n}","typeGuard":"function isFileListResult(data) {\n  return data != null && typeof data === 'object' && Array.isArray(data['items']) && data['items'].every((i) => typeof i?.name === 'string');\n}","tryCatchPattern":"try {\n  const names = await list(token);\n} catch (e) {\n  if (String(e.message).startsWith('Get File List Error')) {\n    const body = JSON.parse(String(e.message).replace('Get File List Error: ', ''));\n    // inspect body.code (e.g. InvalidParameter) and re-auth if needed\n  } else {\n    throw e;\n  }\n}","preventionTips":["Re-authenticate before long-running backup sessions so drive_id is fresh","Validate that res.data contains `items` before mapping (guard against schema drift)","Log the serialized body for alipan API changes","Pin/verify the drive_id matches default_drive_id from getDriveInfo"],"tags":["api","response-schema","aliyun-drive","backup"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"594d32ede96acd106b0256deaa8bb440ffcdff40","analyzedAt":"2026-09-02T18:12:21.811Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}