jackwener/OpenCLI · warning · EmptyResultError
chatgpt read
Error message
chatgpt read
What it means
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.
Source
Thrown at clis/chatgpt/read.js:34
description: 'Read messages in the current ChatGPT web conversation',
domain: CHATGPT_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
navigateBefore: false,
args: [
{ name: 'markdown', type: 'boolean', default: false, help: 'Emit assistant replies as markdown' },
],
columns: ['Index', 'Role', 'Text'],
func: async (page, kwargs) => {
const wantMarkdown = normalizeBooleanFlag(kwargs.markdown, false);
// ensureOnChatGPT now waits for the composer selector after navigating,
// so the previous standalone 2 s settle is redundant.
await ensureOnChatGPT(page);
await ensureChatGPTLogin(page, 'ChatGPT read requires a logged-in ChatGPT session.');
const messages = await getVisibleMessages(page);
if (!messages.length) {
throw new EmptyResultError('chatgpt read', 'No visible ChatGPT messages were found in the current conversation.');
}
return messages.map((message) => ({
Index: message.Index,
Role: message.Role,
Text: wantMarkdown && message.Role === 'Assistant' && message.Html
? (messageHtmlToMarkdown(message.Html) || message.Text)
: message.Text,
}));
},
});
View on GitHub (pinned to 49907e53dc)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure a conversation with content is open
if (!/\/c\/[0-9a-f-]+/i.test(page.url())) {
throw new Error('Navigate to an existing conversation before running chatgpt read');
} Type guard
function hasMessages(m) { return Array.isArray(m) && m.length > 0; } Try / catch
try {
const messages = await run(['chatgpt', 'read']);
} catch (err) {
if (String(err.message).includes('chatgpt read')) {
console.log('No visible messages — open a conversation with content and retry.');
}
} Prevention
- 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.
When it happens
Trigger: Running `chatgpt read` on a page where ensureOnChatGPT succeeded but no visible message nodes exist (empty new chat, wrong tab/page, or unreadable conversation).
Common situations: 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.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- Failed to export generated ChatGPT image assets
- chatgpt project-list
- discord-app channels
- linkedin timeline
- 未抓取到创作者后台文章 (page=${articlePage})。可能页面尚未完成渲染或无文章。
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/69335df515a4a094.
Report an issue: GitHub.