jackwener/OpenCLI · error · EmptyResultError

chatgpt history

Error message

chatgpt history

What it means

The `chatgpt history` command throws EmptyResultError('chatgpt history') when getConversationList returns zero conversation links from the sidebar. It signals that no sidebar conversation links were visible, so there is nothing to slice by --limit.

Source

Thrown at clis/chatgpt/history.js:35

    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [
        { name: 'limit', type: 'int', default: 20, help: 'Max conversations to show' },
    ],
    columns: ['Index', 'Id', 'Title', 'Url'],
    func: async (page, kwargs) => {
        const limit = requirePositiveInt(
            Number(kwargs.limit ?? 20),
            'chatgpt history --limit',
            'Example: opencli chatgpt history --limit 20',
        );
        await ensureOnChatGPT(page);
        await ensureChatGPTLogin(page, 'ChatGPT history requires a logged-in ChatGPT session.');
        const conversations = await getConversationList(page);
        if (!conversations.length) {
            throw new EmptyResultError('chatgpt history', 'No ChatGPT conversation links were visible in the sidebar.');
        }
        return conversations.slice(0, limit);
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open chatgpt.com in a browser and confirm the sidebar lists conversations; disable the sidebar collapse state if hidden.
  2. Retry after the page fully loads (transient extraction race).
  3. Verify the correct logged-in account (the cookie session may point to an empty account).
  4. If the sidebar renders conversations but extraction is empty, the selectors likely changed — update the library.

Example fix

// before
opencli chatgpt history --limit 20
// after
# confirm conversations exist in the browser, ensure window is wide enough to show the sidebar, then
opencli chatgpt history --limit 20
Defensive patterns

Strategy: retry

Validate before calling

// Ensure the session account actually has history before listing
const accountPage = await open('https://chatgpt.com');
// or simply guard the result:
const conversations = await run('chatgpt history', '--limit', '20').catch(() => []);
if (!conversations.length) console.warn('Sidebar empty: new account or hidden sidebar');

Type guard

function hasSidebarHistory(conversations) {
  return Array.isArray(conversations) && conversations.length > 0;
}

Try / catch

try {
  const conversations = await run('chatgpt history', '--limit', '20');
} catch (err) {
  if (String(err.message).includes('chatgpt history')) {
    // empty account, collapsed sidebar, or selector drift — inspect manually
    return [];
  }
  throw err;
}

Prevention

When it happens

Trigger: `opencli chatgpt history` after ensureOnChatGPT + ensureChatGPTLogin pass, but the sidebar contains no conversation anchor elements — new account with no history, sidebar collapsed, DOM changes, or the page not fully loaded when extraction ran.

Common situations: Brand-new ChatGPT account with zero conversations; sidebar hidden/collapsed by ChatGPT UI or a small viewport; account switched so the persistent session cookie belongs to an empty account; ChatGPT redesign changing sidebar selectors.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/f8d117d07cc0ba46. Report an issue: GitHub.