{"record":{"id":"02445d7f8e525931","repo":"jackwener/OpenCLI","slug":"xiaohongshu-delete-note-malformed-context-payl","errorCode":null,"errorMessage":"xiaohongshu/delete-note: malformed ${context} payload","messagePattern":"xiaohongshu/delete-note: malformed (.+?) payload","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/delete-note.js","lineNumber":26,"sourceCode":" *   3. Locate the row whose `data-impression` JSON contains the target noteId\n *   4. Click the inline `<span class=\"control data-del\">` action\n *   5. Click \"确定\" in the `.d-modal-footer` confirmation modal\n *   6. Poll for the row disappearing from the list\n *\n * Requires: logged into creator.xiaohongshu.com in Chrome.\n */\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, AuthRequiredError, CliError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\nimport { unwrapEvaluateResult } from './shared.js';\nconst NOTE_MANAGER_URL = 'https://creator.xiaohongshu.com/new/note-manager';\nconst ROW_SETTLE_MS = 3000;\nconst MODAL_SETTLE_MS = 2000;\nconst VERIFY_TIMEOUT_MS = 10_000;\nconst VERIFY_POLL_MS = 1000;\nconst NOTE_ID_RE = /^[0-9a-f]{24}$/i;\nfunction requireEvaluateString(payload, context) {\n    if (typeof payload !== 'string') {\n        throw new CommandExecutionError(`xiaohongshu/delete-note: malformed ${context} payload`);\n    }\n    return payload;\n}\nfunction requireEvaluateBoolean(payload, context) {\n    if (typeof payload !== 'boolean') {\n        throw new CommandExecutionError(`xiaohongshu/delete-note: malformed ${context} payload`);\n    }\n    return payload;\n}\nfunction requireEvaluateObject(payload, context) {\n    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n        throw new CommandExecutionError(`xiaohongshu/delete-note: malformed ${context} payload`);\n    }\n    return payload;\n}\nfunction requireActionResult(payload, context) {\n    const result = requireEvaluateObject(payload, context);\n    if (typeof result.ok !== 'boolean') {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/delete-note.js#L8-L44","documentation":"requireEvaluateString validates that a value returned from a page.evaluate script is a string before it is used (here for the current URL). If the browser context returned undefined, null, or a non-string, the library throws this CommandExecutionError naming the context. It protects downstream URL parsing from non-string input.","triggerScenarios":"An in-page evaluate used by currentUrl returned undefined/null or a non-string — e.g. the script threw and returned undefined, the tab navigated mid-evaluate, or the evaluate ran in a context where `location.href` was not accessible.","commonSituations":"Page navigation or crash during evaluate; running against a non-xiaohongshu or chrome-error page; automation timing issues where the target frame was not ready.","solutions":["Ensure the page is fully loaded on a xiaohongshu.com URL before running the delete-note command","Retry the command — transient navigation can make evaluate return undefined","Add navigation/selector waits to stabilize the page before evaluating","Log the raw evaluate payload on failure to see what the page returned"],"exampleFix":"// before\nconst payload = await page.evaluate(() => location.href);\n// after\nawait page.waitForFunction(() => location.hostname.includes('xiaohongshu.com'));\nconst payload = await page.evaluate(() => location.href);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isEvaluateString(v) { return typeof v === 'string'; }","tryCatchPattern":"try {\n  await deleteNote({ noteId });\n} catch (e) {\n  if (e instanceof CommandExecutionError && /malformed .* payload/.test(e.message)) {\n    // page likely navigated or evaluate failed; reload and retry once\n  } else { throw e; }\n}","preventionTips":["Wait for the page to be fully loaded and stable before running delete flows","Keep the tab on xiaohongshu.com for the whole operation","Retry once on transient evaluate failures caused by navigation races"],"tags":["puppeteer","type-mismatch","evaluate","scraping"],"backgroundTag":"evaluate-payload-type-mismatch","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}