jackwener/OpenCLI · error · CommandExecutionError

抖音后台管理删除失败: ${JSON.stringify(result)}

Error message

抖音后台管理删除失败: ${JSON.stringify(result)}

What it means

Thrown by deleteViaCreatorManage when an in-page delete via the creator-micro content manage UI returns a result object whose ok flag is falsy (e.g. card_not_found). The library runs injected page JS to click the delete card and requires an explicit ok:true. The message embeds the whole result (reason, aweme_id, index, listCount) for diagnosis.

Source

Thrown at clis/douyin/delete.js:98

          if (!confirmButton) return { ok: false, reason: 'confirm_button_not_found', aweme_id: target.item.aweme_id, item_id: target.item.item_id };
          confirmButton.click();
          for (let wait = 0; wait < 20; wait += 1) {
            await sleep(500);
            const after = await loadTarget();
            if (!after.ok && after.reason === 'not_found') {
              return { ok: true, aweme_id: target.item.aweme_id, item_id: target.item.item_id, title: target.title };
            }
          }
          return { ok: false, reason: 'delete_not_confirmed', aweme_id: target.item.aweme_id, item_id: target.item.item_id };
        }
        await sleep(500);
      }
      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 };
    })()
  `), '抖音后台管理删除响应异常');

    if (!result?.ok) {
        throw new CommandExecutionError(`抖音后台管理删除失败: ${JSON.stringify(result)}`);
    }
    return result;
}

async function findWorkListItem(page, workId) {
    const data = await browserFetch(page, 'GET', `https://creator.douyin.com${WORK_LIST_URL}`, { timeoutMs: 8000 });
    const list = data.data?.work_list ?? data.aweme_list ?? data.work_list ?? [];
    if (!Array.isArray(list)) {
        throw new CommandExecutionError('抖音作品列表响应缺少 work_list/aweme_list');
    }
    return list.find((entry) => String(entry.aweme_id || '') === workId || String(entry.item_id || '') === workId) || null;
}

cli({
    site: 'douyin',
    name: 'delete',
    access: 'write',
    description: '删除作品(优先使用创作者后台作品管理;找不到时回退到旧删除接口)',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read result.reason in the message: if card_not_found, confirm the work still exists on the manage page
  2. Use the API delete path (aweme/delete endpoint) instead of the UI-manage path if selectors broke
  3. Load more items or adjust WORK_LIST_URL status/count params if the item is beyond the first page
  4. Update injected selectors after a Douyin frontend change

Example fix

// before: rely on UI manage path
await deleteViaCreatorManage(page, awemeId);
// after: fall back to API delete when card is missing
try { await deleteViaCreatorManage(page, awemeId); }
catch (e) { if (String(e).includes('card_not_found')) await deleteViaApi(page, awemeId); else throw e; }
Defensive patterns

Strategy: fallback

Validate before calling

// confirm the work exists in the manage list before invoking UI delete
const item = await findWorkListItem(page, awemeId);
if (!item) throw new Error(`${awemeId} not in work list; skip UI delete`);

Type guard

function isDeleteResultOk(result) {
  return Boolean(result && result.ok === true);
}

Try / catch

try {
  await deleteViaCreatorManage(page, awemeId);
} catch (e) {
  if (String(e).includes('card_not_found')) {
    return deleteViaAwemeDeleteApi(page, awemeId); // API fallback
  } throw e;
}

Prevention

When it happens

Trigger: The target work's card was not found in the manage list (reason 'card_not_found'); the work was already deleted before the call; the manage list is paginated/filtered so the target is not on the first page; DOM selectors changed after a Douyin frontend update so the injected script fails.

Common situations: Deleting a video that was removed manually or by Douyin moderation between lookup and delete; account with many works where the item sits beyond the loaded list (count=20); Douyin UI redesign breaking selectors.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/7f44ee18830a16a1. Report an issue: GitHub.