jackwener/OpenCLI · error · EmptyResultError

opencli notebooklm get

Error message

opencli notebooklm get

What it means

This EmptyResultError is thrown by `opencli notebooklm get` when the session page is not on a notebook view (state.kind !== 'notebook'). The command needs an open notebook to fetch its detail row (id, title, emoji, counts, timestamps).

Source

Thrown at clis/notebooklm/get.js:21

import { NOTEBOOKLM_DOMAIN, NOTEBOOKLM_SITE } from './shared.js';
import { getNotebooklmDetailViaRpc, getNotebooklmPageState, readCurrentNotebooklm, requireNotebooklmSession, } from './utils.js';
cli({
    site: NOTEBOOKLM_SITE,
    name: 'get',
    access: 'read',
    aliases: ['metadata'],
    description: 'Get rich metadata for the currently opened NotebookLM notebook',
    domain: NOTEBOOKLM_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    navigateBefore: false,
    args: [],
    columns: ['id', 'title', 'emoji', 'source_count', 'created_at', 'updated_at', 'url', 'source'],
    func: async (page) => {
        await requireNotebooklmSession(page);
        const state = await getNotebooklmPageState(page);
        if (state.kind !== 'notebook') {
            throw new EmptyResultError('opencli notebooklm get', 'No NotebookLM notebook is open in the adapter session. Run `opencli notebooklm open <notebook>` first.');
        }
        const rpcRow = await getNotebooklmDetailViaRpc(page).catch(() => null);
        if (rpcRow)
            return [rpcRow];
        const current = await readCurrentNotebooklm(page);
        if (!current) {
            throw new EmptyResultError('opencli notebooklm get', 'NotebookLM notebook metadata was not found on the current page.');
        }
        return [{
                ...current,
                emoji: null,
                source_count: null,
                updated_at: null,
            }];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run `opencli notebooklm open <notebook>` first, then `opencli notebooklm get`.
  2. Ensure no other command navigated the shared session page between open and get.
  3. Re-establish the adapter session if page state appears stale.

Example fix

// before
opencli notebooklm get   # no notebook open
// after
opencli notebooklm open "My Notebook"
opencli notebooklm get
Defensive patterns

Strategy: validation

Validate before calling

const state = await getNotebooklmPageState(page);
if (state.kind !== 'notebook') {
  await runCli(['notebooklm', 'open', notebookId]);
}

Type guard

const isNotebookOpen = (state) => state?.kind === 'notebook';

Try / catch

try {
  return await runCli(['notebooklm', 'get']);
} catch (e) {
  if (String(e.message).includes('No NotebookLM notebook is open')) {
    await runCli(['notebooklm', 'open', notebookId]);
    return await runCli(['notebooklm', 'get']);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `opencli notebooklm get` before any notebook was opened, after navigating to the NotebookLM home/list, or when the session was restarted and page state reset.

Common situations: Script assumes a notebook is still open from a previous step that failed or navigated away; concurrent commands changed the shared session page.

Related errors


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