{"record":{"id":"970a9e8bc85539ee","repo":"jackwener/OpenCLI","slug":"xiaohongshu-delete-note-failed-err-message","errorCode":null,"errorMessage":"xiaohongshu/delete-note failed: ${err?.message ?? String(err)}","messagePattern":"xiaohongshu/delete-note failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/delete-note.js","lineNumber":247,"sourceCode":"            const VERIFY_ITERATIONS = Math.ceil(VERIFY_TIMEOUT_MS / VERIFY_POLL_MS);\n            let stillPresent = true;\n            for (let i = 0; i < VERIFY_ITERATIONS; i++) {\n                await page.wait({ time: VERIFY_POLL_MS / 1000 });\n                const probe = requireEvaluateBoolean(unwrapEvaluateResult(await page.evaluate(buildVerifyGoneScript(noteId))), 'verify-gone');\n                if (probe === false) {\n                    stillPresent = false;\n                    break;\n                }\n            }\n            if (stillPresent) {\n                throw new CommandExecutionError(`xiaohongshu/delete-note: note ${noteId} still visible after confirm click; deletion may not have committed.`);\n            }\n            return [{ status: 'deleted', note_id: noteId, message: 'Delete confirmed and note row disappeared.' }];\n        }\n        catch (err) {\n            if (err instanceof CliError)\n                throw err;\n            throw new CommandExecutionError(`xiaohongshu/delete-note failed: ${err?.message ?? String(err)}`);\n        }\n    },\n});\nexport const __test__ = {\n    normalizeNoteId,\n    buildLocateAndMaybeDeleteScript,\n    buildVerifyGoneScript,\n};\n","sourceCodeStart":229,"sourceCodeEnd":256,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/delete-note.js#L229-L256","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait cli.run('xiaohongshu/delete-note', { input: '65f1abc123' });\n// after\nawait cli.run('xiaohongshu/delete-note', { input: 'https://www.xiaohongshu.com/explore/65f1abc123?xsec_token=AB...' });","handlingStrategy":"try-catch","validationCode":"// Validate input before calling\nfunction isValidNoteInput(input) {\n  return typeof input === 'string' && input.trim().length > 0 &&\n    (/^https?:\\/\\//.test(input) || /^[0-9a-f]{24}$/i.test(input.trim()));\n}\nif (!isValidNoteInput(noteInput)) throw new Error('invalid note id or url');","typeGuard":"function isCliError(e) { return e instanceof Error && e.name === 'CliError'; }","tryCatchPattern":"try {\n  await cli.run('xiaohongshu/delete-note', { input: noteInput });\n} catch (err) {\n  if (err instanceof CliError) throw err; // e.g. security block\n  console.error('delete-note inner failure:', err?.message ?? String(err));\n  // retry transient failures or rethrow\n}","preventionTips":["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."],"tags":["cli","wrapper-error","web-automation"],"backgroundTag":"command-execution-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}