{"record":{"id":"a657de86e49317a4","repo":"jackwener/OpenCLI","slug":"work-list-aweme-list","errorCode":null,"errorMessage":"抖音作品列表响应缺少 work_list/aweme_list","messagePattern":"抖音作品列表响应缺少 work_list/aweme_list","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/douyin/delete.js","lineNumber":107,"sourceCode":"          return { ok: false, reason: 'delete_not_confirmed', aweme_id: target.item.aweme_id, item_id: target.item.item_id };\n        }\n        await sleep(500);\n      }\n      return { ok: false, reason: 'card_not_found', aweme_id: target.item.aweme_id, item_id: target.item.item_id, index: target.index, listCount: target.listCount };\n    })()\n  `), '抖音后台管理删除响应异常');\n\n    if (!result?.ok) {\n        throw new CommandExecutionError(`抖音后台管理删除失败: ${JSON.stringify(result)}`);\n    }\n    return result;\n}\n\nasync function findWorkListItem(page, workId) {\n    const data = await browserFetch(page, 'GET', `https://creator.douyin.com${WORK_LIST_URL}`, { timeoutMs: 8000 });\n    const list = data.data?.work_list ?? data.aweme_list ?? data.work_list ?? [];\n    if (!Array.isArray(list)) {\n        throw new CommandExecutionError('抖音作品列表响应缺少 work_list/aweme_list');\n    }\n    return list.find((entry) => String(entry.aweme_id || '') === workId || String(entry.item_id || '') === workId) || null;\n}\n\ncli({\n    site: 'douyin',\n    name: 'delete',\n    access: 'write',\n    description: '删除作品（优先使用创作者后台作品管理；找不到时回退到旧删除接口）',\n    domain: 'creator.douyin.com',\n    strategy: Strategy.COOKIE,\n    siteSession: 'persistent',\n    args: [\n        { name: 'aweme_id', required: true, positional: true, help: '作品 ID / item_id' },\n    ],\n    columns: ['status'],\n    func: async (page, kwargs) => {\n        const awemeId = readAwemeId(kwargs.aweme_id);","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/douyin/delete.js#L89-L125","documentation":"Thrown by findWorkListItem when the work_list API response's candidate lists (data.work_list, aweme_list, work_list) are all absent or the resolved value is not an array. The library needs the list to match aweme_id/item_id against the requested work. Thrown to prevent silently treating a bad response as an empty list.","triggerScenarios":"Session expired so the API returns an error envelope instead of a list; Douyin renames or nests work_list in the response; risk-control returns HTML/JSON error with 200 status; network truncation yields partial JSON.","commonSituations":"Running delete right after cookies expired; Douyin API version drift after a backend update; account state (e.g. restricted) causing error payloads.","solutions":["Log the full response to see the actual shape and add the new path to the fallback chain","Re-authenticate (run the login flow) and retry — most often a session problem","Check status=0/count params in WORK_LIST_URL still match the current API","If the new shape nests the array (e.g. data.data.work_list.items), update the extraction"],"exampleFix":"// before\nconst list = data.data?.work_list ?? data.aweme_list ?? data.work_list ?? [];\n// after\nconst list = data.data?.work_list ?? data.work_list ?? data.aweme_list ?? data.data?.aweme_list ?? [];\nif (!Array.isArray(list)) throw new Error('shape: ' + JSON.stringify(data).slice(0, 300));","handlingStrategy":"type-guard","validationCode":"const data = await browserFetch(page, 'GET', listUrl);\nconst list = data.data?.work_list ?? data.aweme_list ?? data.work_list;\nif (!Array.isArray(list) || list.length === 0) throw new Error('unexpected work list shape: ' + JSON.stringify(data).slice(0, 300));","typeGuard":"function extractWorkList(data) {\n  const l = data?.data?.work_list ?? data?.aweme_list ?? data?.work_list;\n  return Array.isArray(l) ? l : null;\n}","tryCatchPattern":"try {\n  const item = await findWorkListItem(page, awemeId);\n} catch (e) {\n  if (/缺少 work_list/.test(e.message)) {\n    await reLoginIfNeeded(page); // most common cause is expired session\n    return findWorkListItem(page, awemeId);\n  } throw e;\n}","preventionTips":["Verify session cookies are valid before listing works","Log full responses to detect Douyin response-shape renames quickly","Treat empty-but-shaped responses separately from malformed responses","Retry once after re-auth on list-shape errors"],"tags":["douyin","delete","api-error","schema-change"],"backgroundTag":"response-missing-required-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}