{"record":{"id":"7b887e46693589c5","repo":"jackwener/OpenCLI","slug":"creator-xiaohongshu-com","errorCode":null,"errorMessage":"creator.xiaohongshu.com","messagePattern":"creator\\.xiaohongshu\\.com","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/delete-note.js","lineNumber":170,"sourceCode":"        },\n        {\n            name: 'execute',\n            type: 'boolean',\n            default: false,\n            help: 'Actually click delete + confirm. Default is dry-run target verification only.',\n        },\n    ],\n    columns: ['status', 'note_id', 'message'],\n    func: async (page, kwargs) => {\n        try {\n            const noteId = normalizeNoteId(kwargs['note-id']);\n            const execute = kwargs.execute === true;\n            await page.goto(NOTE_MANAGER_URL);\n            await page.wait({ time: ROW_SETTLE_MS / 1000 });\n            // Detect login redirect (creator.xiaohongshu.com bounces to /login on auth failure)\n            const currentUrl = requireEvaluateString(unwrapEvaluateResult(await page.evaluate('() => location.href')), 'current-url');\n            if (typeof currentUrl === 'string' && /\\/login(?:[/?#]|$)/i.test(new URL(currentUrl).pathname + new URL(currentUrl).search)) {\n                throw new AuthRequiredError('creator.xiaohongshu.com');\n            }\n            // Step 1: ensure 已发布 tab is active (delete only exposed there).\n            const tabClicked = requireEvaluateBoolean(unwrapEvaluateResult(await page.evaluate(`\n      () => {\n        const isVisible = (el) => !!el && el.offsetParent !== null;\n        for (const el of document.querySelectorAll('a, button, [role=\"tab\"], div')) {\n          const text = (el.innerText || el.textContent || '').trim();\n          if (text === '已发布' && isVisible(el)) {\n            el.click();\n            return true;\n          }\n        }\n        return false;\n      }\n    `)), 'published-tab');\n            if (!tabClicked) {\n                throw new CommandExecutionError('xiaohongshu/delete-note: 已发布 tab not found on note-manager; xhs creator UI may have changed.');\n            }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/delete-note.js#L152-L188","documentation":"After navigating to the creator note-manager page, the CLI checks location.href; if it points at a /login path, the creator session is not authenticated, so an AuthRequiredError named 'creator.xiaohongshu.com' is thrown to tell the caller (and any CLI wrapper) that interactive browser login is required before this command can run.","triggerScenarios":"Running delete-note without being logged into creator.xiaohongshu.com in the controlled Chrome profile; the login cookie/session having expired; running on a fresh machine or fresh browser profile with no XHS session; XHS invalidating the session server-side.","commonSituations":"CI/headless environments where the user never logged in; sessions expiring overnight; cookie cleanup extensions wiping auth cookies; running under a different Chrome profile than the one used to log in.","solutions":["Open Chrome with the same profile the CLI uses, visit https://creator.xiaohongshu.com, and complete the login (QR code scan)","Re-run the delete-note command after confirming the note-manager page loads logged-in in that browser","If the CLI supports a login/bootstrap command, run it first to establish the session"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check login state before running the command:\nconst href = await page.evaluate('() => location.href');\nif (/\\/login(?:[/?#]|$)/i.test(new URL(href).pathname + new URL(href).search)) {\n  throw new Error('Not logged into creator.xiaohongshu.com — log in first');\n}","typeGuard":"function isLoginUrl(href) {\n  try {\n    const u = new URL(href);\n    return /\\/login(?:[/?#]|$)/i.test(u.pathname + u.search);\n  } catch { return false; }\n}","tryCatchPattern":"try {\n  await cli('xiaohongshu', 'delete-note', { note: noteId });\n} catch (err) {\n  if (err instanceof AuthRequiredError && err.message === 'creator.xiaohongshu.com') {\n    console.error('Open Chrome with the CLI profile, log in at https://creator.xiaohongshu.com (QR scan), then retry.');\n  } else throw err;\n}","preventionTips":["Log into creator.xiaohongshu.com in the exact Chrome profile the CLI drives before automating","Re-check the session periodically; XHS sessions expire and cookies can be wiped by extensions","Avoid running this in fresh headless profiles without an established login"],"tags":["authentication","browser-automation","session"],"backgroundTag":"auth-required-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}