jackwener/OpenCLI · error · CommandExecutionError
xiaohongshu/delete-note failed: ${err?.message ?? String(err
Error message
xiaohongshu/delete-note failed: ${err?.message ?? String(err)} What it means
This is a generic wrapper error thrown by the xiaohongshu/delete-note CLI command. Any unexpected exception raised while locating and deleting a note (page navigation failure, script evaluation error, element not found, timeout) is caught and re-thrown as a CommandExecutionError whose message embeds the original error message. Errors that are already CliError instances are passed through unchanged, so this wrapper only appears for non-CliError failures.
Source
Thrown at clis/xiaohongshu/delete-note.js:247
const VERIFY_ITERATIONS = Math.ceil(VERIFY_TIMEOUT_MS / VERIFY_POLL_MS);
let stillPresent = true;
for (let i = 0; i < VERIFY_ITERATIONS; i++) {
await page.wait({ time: VERIFY_POLL_MS / 1000 });
const probe = requireEvaluateBoolean(unwrapEvaluateResult(await page.evaluate(buildVerifyGoneScript(noteId))), 'verify-gone');
if (probe === false) {
stillPresent = false;
break;
}
}
if (stillPresent) {
throw new CommandExecutionError(`xiaohongshu/delete-note: note ${noteId} still visible after confirm click; deletion may not have committed.`);
}
return [{ status: 'deleted', note_id: noteId, message: 'Delete confirmed and note row disappeared.' }];
}
catch (err) {
if (err instanceof CliError)
throw err;
throw new CommandExecutionError(`xiaohongshu/delete-note failed: ${err?.message ?? String(err)}`);
}
},
});
export const __test__ = {
normalizeNoteId,
buildLocateAndMaybeDeleteScript,
buildVerifyGoneScript,
};
View on GitHub (pinned to 49907e53dc)
Solutions
- Read the embedded `err?.message` in the error message to identify the underlying cause and fix that first.
- Re-run with a full note URL (including xsec_token) rather than a bare note ID to reduce risk-control blocks.
- Verify the note exists and is accessible while logged in; retry a transient failure once.
- If the inner message points at a script/DOM failure, update the locate-and-delete script selectors to match the current page DOM.
Example fix
// before
await cli.run('xiaohongshu/delete-note', { input: '65f1abc123' });
// after
await cli.run('xiaohongshu/delete-note', { input: 'https://www.xiaohongshu.com/explore/65f1abc123?xsec_token=AB...' }); Defensive patterns
Strategy: try-catch
Validate before calling
// Validate input before calling
function isValidNoteInput(input) {
return typeof input === 'string' && input.trim().length > 0 &&
(/^https?:\/\//.test(input) || /^[0-9a-f]{24}$/i.test(input.trim()));
}
if (!isValidNoteInput(noteInput)) throw new Error('invalid note id or url'); Type guard
function isCliError(e) { return e instanceof Error && e.name === 'CliError'; } Try / catch
try {
await cli.run('xiaohongshu/delete-note', { input: noteInput });
} catch (err) {
if (err instanceof CliError) throw err; // e.g. security block
console.error('delete-note inner failure:', err?.message ?? String(err));
// retry transient failures or rethrow
} Prevention
- Always pass a full note URL with xsec_token rather than a bare note ID.
- Confirm you are logged in and the session is fresh before batch deletes.
- Retry once on transient failures; inspect the embedded inner message before changing code.
- Log the wrapped inner message so the real root cause is visible.
When it happens
Trigger: Calling `xiaohongshu/delete-note` when the browser page fails to load the note page, the in-page locate/delete script (buildLocateAndMaybeDeleteScript) throws during page.evaluate, normalizeNoteId rejects the input, or any runtime error (network drop, selector mismatch, timeout) occurs before the success path returns the 'deleted' status.
Common situations: Passing a malformed note ID or URL; the note page failing to render because of risk control or login expiry; a stale/deleted note ID; flaky network causing page.goto or evaluate to time out; running against an updated Xiaohongshu DOM where the delete flow's selectors no longer match.
Related errors
- Failed to ${execute ? 'clear' : 'count'} ${draftType} drafts
- Not a git repository
- Working tree not clean: ${status}
- Stale .git/index.lock found — remove it first
- 12306 whoami failed: ${probe.detail}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/970a9e8bc85539ee.
Report an issue: GitHub.