{"record":{"id":"69335df515a4a094","repo":"jackwener/OpenCLI","slug":"chatgpt-read","errorCode":null,"errorMessage":"chatgpt read","messagePattern":"chatgpt read","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/chatgpt/read.js","lineNumber":34,"sourceCode":"    description: 'Read messages in the current ChatGPT web conversation',\n    domain: CHATGPT_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'markdown', type: 'boolean', default: false, help: 'Emit assistant replies as markdown' },\n    ],\n    columns: ['Index', 'Role', 'Text'],\n    func: async (page, kwargs) => {\n        const wantMarkdown = normalizeBooleanFlag(kwargs.markdown, false);\n        // ensureOnChatGPT now waits for the composer selector after navigating,\n        // so the previous standalone 2 s settle is redundant.\n        await ensureOnChatGPT(page);\n        await ensureChatGPTLogin(page, 'ChatGPT read requires a logged-in ChatGPT session.');\n        const messages = await getVisibleMessages(page);\n        if (!messages.length) {\n            throw new EmptyResultError('chatgpt read', 'No visible ChatGPT messages were found in the current conversation.');\n        }\n        return messages.map((message) => ({\n            Index: message.Index,\n            Role: message.Role,\n            Text: wantMarkdown && message.Role === 'Assistant' && message.Html\n                ? (messageHtmlToMarkdown(message.Html) || message.Text)\n                : message.Text,\n        }));\n    },\n});\n","sourceCodeStart":16,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt/read.js#L16-L45","documentation":"EmptyResultError thrown by `chatgpt read` when `getVisibleMessages(page)` returns zero messages from the current conversation. The page loaded and login passed, but no chat messages were visible to scrape.","triggerScenarios":"Running `chatgpt read` on a page where ensureOnChatGPT succeeded but no visible message nodes exist (empty new chat, wrong tab/page, or unreadable conversation).","commonSituations":"Reading a brand-new empty conversation; conversation failed to load due to network; ChatGPT UI redesign changed message selectors; landed on the home/landing page instead of a conversation.","solutions":["Navigate to an existing conversation with messages, then re-run `chatgpt read`.","Wait for the conversation to fully load and retry.","Confirm in the browser that messages are visible at the current URL.","Update message selectors if the ChatGPT DOM changed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure a conversation with content is open\nif (!/\\/c\\/[0-9a-f-]+/i.test(page.url())) {\n  throw new Error('Navigate to an existing conversation before running chatgpt read');\n}","typeGuard":"function hasMessages(m) { return Array.isArray(m) && m.length > 0; }","tryCatchPattern":"try {\n  const messages = await run(['chatgpt', 'read']);\n} catch (err) {\n  if (String(err.message).includes('chatgpt read')) {\n    console.log('No visible messages — open a conversation with content and retry.');\n  }\n}","preventionTips":["Open an existing conversation with messages before reading.","Wait for conversation content to load (avoid reading an empty new chat).","Confirm the browser tab is on the conversation, not the landing page.","Handle empty conversations explicitly in automation scripts."],"tags":["empty-result","chatgpt","browser-automation","scraping"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}