jackwener/OpenCLI · error · EmptyResultError
Draft ${id} was not found in ${draftType} drafts. Run opencl
Error message
Draft ${id} was not found in ${draftType} drafts. Run opencli xiaohongshu drafts --type ${draftType} to list current ids. What it means
draftNotFound is thrown when the requested draft id does not exist among the entries read from the Xiaohongshu draft database for the given draft type. The command aborts before any delete, and the message points to the drafts listing command to discover valid ids.
Source
Thrown at clis/xiaohongshu/draft-delete.js:78
description: '删除一条小红书本地草稿',
domain: 'creator.xiaohongshu.com',
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
args: [
{ name: 'id', positional: true, required: true, help: 'Draft id returned by `opencli xiaohongshu drafts`' },
{ name: 'type', default: 'image', help: 'Draft type: image, video, article, audio' },
{ name: 'execute', type: 'bool', default: false, help: 'Actually delete the local draft. Default is dry-run verification only.' },
],
columns: ['status', 'id', 'type', 'message'],
func: async (page, kwargs) => {
const id = normalizeDraftId(kwargs.id);
const draftType = normalizeDraftType(kwargs.type);
const execute = kwargs.execute === true;
await ensureDraftDbPage(page);
const entries = await readDraftEntries(page, draftType);
const entry = findDraftEntry(entries, id);
if (!entry) throw draftNotFound(id, draftType, 'xiaohongshu/draft-delete');
const row = normalizeDraftRecord(entry.row, entry.key, draftType, 1);
if (!execute) {
return [{
status: 'dry-run',
id: row.id,
type: draftType,
message: 'Draft exists. Re-run with --execute to delete.',
}];
}
const storeName = STORE_NAME_MAP[draftType];
const result = unwrapBrowserResult(await page.evaluate(deleteDraftScript(storeName, entry.key)));
if (!result?.ok) {
throw new CommandExecutionError(result?.error || `Failed to delete draft ${row.id}`);
}
if (!result.deleted) {
throw new CommandExecutionError(`Draft ${row.id} still exists after delete`);
}
return [{View on GitHub (pinned to 49907e53dc)
Solutions
- Run 'opencli xiaohongshu drafts --type <type>' to list current ids and copy the correct one
- Confirm the --type matches the draft kind the id belongs to
- Check the draft wasn't already deleted (list first)
- Verify id normalization — pass the id exactly as listed
Example fix
// before opencli xiaohongshu draft-delete --id draft_999 --type note // after: list to get a valid id first opencli xiaohongshu drafts --type note opencli xiaohongshu draft-delete --id <validId> --type note --execute
Defensive patterns
Strategy: validation
Validate before calling
const drafts = await opencli xiaohongshu drafts --type type;
if (!drafts.some(d => d.id === targetId)) throw new Error(`Draft ${targetId} not found in ${type} drafts`); Type guard
function draftExists(drafts, id) { return Array.isArray(drafts) && drafts.some(d => d && d.id === id); } Try / catch
try {
await opencli xiaohongshu draft-delete --id id --type type --execute;
} catch (e) {
if (/was not found in .* drafts/.test(e.message)) {
const list = await opencli xiaohongshu drafts --type type;
// pick a valid id from list and retry, or surface to the user
} else throw e;
} Prevention
- Always list current ids before delete operations
- Pass --type matching the draft kind
- Treat ids as ephemeral — re-fetch after any mutation
- Use dry-run first to confirm the id resolves
When it happens
Trigger: Calling the xiaohongshu draft-delete command (clis/xiaohongshu/draft-delete.js) with an --id that is absent from readDraftEntries results for the given --type.
Common situations: Stale/hardcoded id after the draft was already deleted; wrong --type so the id is looked up in the wrong draft collection; typo'd or un-normalized id; draft db page not in sync.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Draft ${id} was not found in ${draftType} drafts. Run opencl
- Note ${noteId} not found or unavailable — it may have been d
- NOT_FOUND
- NOT_FOUND
- bilibili creator-stats ${bvid}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/090e15b60484b52d.
Report an issue: GitHub.