{"record":{"id":"4bed5687876d4db1","repo":"jackwener/OpenCLI","slug":"notebooklm-label-failed-error-message-er","errorCode":null,"errorMessage":"NotebookLM ${label} failed: ${error?.message || error}","messagePattern":"NotebookLM (.+?) failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/rpc.js","lineNumber":16,"sourceCode":"import { AuthRequiredError, CliError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { NOTEBOOKLM_DOMAIN, parseTrustedNotebooklmUrl } from './shared.js';\n\nconst NOTEBOOKLM_RPC_PATH = '/_/LabsTailwindUi/data/batchexecute';\n\nfunction requireNotebooklmObject(value, label) {\n    if (!value || typeof value !== 'object' || Array.isArray(value)) {\n        throw new CommandExecutionError(`NotebookLM ${label} returned a malformed Browser Bridge payload`);\n    }\n    return value;\n}\n\nfunction rethrowNotebooklmTransport(error, label) {\n    if (error instanceof CliError)\n        throw error;\n    throw new CommandExecutionError(`NotebookLM ${label} failed: ${error?.message || error}`);\n}\n\nexport function unwrapNotebooklmEvaluateResult(payload) {\n    if (payload && typeof payload === 'object' && !Array.isArray(payload) && 'session' in payload && 'data' in payload) {\n        return payload.data;\n    }\n    return payload;\n}\n\nexport function extractNotebooklmPageAuthFromHtml(html, sourcePath = '/', preferredTokens) {\n    const csrfMatch = html.match(/\"SNlM0e\":\"([^\"]+)\"/);\n    const sessionMatch = html.match(/\"FdrFJe\":\"([^\"]+)\"/);\n    const csrfToken = preferredTokens?.csrfToken?.trim() || (csrfMatch ? csrfMatch[1] : '');\n    const sessionId = preferredTokens?.sessionId?.trim() || (sessionMatch ? sessionMatch[1] : '');\n    if (!csrfToken || !sessionId) {\n        throw new CliError('NOTEBOOKLM_TOKENS', 'NotebookLM page tokens were not found in the current page HTML', 'Open the NotebookLM notebook page in Chrome, wait for it to finish loading, then retry with --verbose if it still fails.');\n    }\n    return { csrfToken, sessionId, sourcePath: sourcePath || '/', authuser: preferredTokens?.authuser ?? '' };","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/rpc.js#L1-L34","documentation":"rethrowNotebooklmTransport is the catch-side wrapper for Browser Bridge operations (page auth probe, in-page fetch). If the caught error is already a CliError it is rethrown unchanged; otherwise the original error (possibly a browser automation failure, navigation error, or TypeError) is converted into a CommandExecutionError with the label and the original message appended. This normalizes non-library exceptions into the CLI's error hierarchy while preserving the cause.","triggerScenarios":"Any throw inside probeNotebooklmPageAuth or fetchNotebooklmInPage from page.evaluate/browser bridge machinery that is not already a CliError — e.g. browser tab closed, evaluate timed out, navigation interrupted, or a raw JS exception inside the injected script.","commonSituations":"Chrome was closed mid-operation by the user or by idle tab discard; slow network caused the evaluate to time out; a page reload/redirect happened between probe steps; an uncaught exception in the injected fetch script.","solutions":["Read error?.message in the output — it carries the underlying cause; fix that cause","Reopen the target NotebookLM tab and ensure the browser session stays alive during the command","Retry the command; transient navigation/timing issues often resolve","Run with --verbose for the full underlying stack and raw error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!browser.isConnected() || (await browser.pages()).length === 0) {\n  throw new Error('No live Chrome tab available for Browser Bridge operations');\n}","typeGuard":"function isCliError(e) {\n  return e instanceof CliError;\n}","tryCatchPattern":"try {\n  await fetchNotebooklmInPage(page, url);\n} catch (e) {\n  console.error(`NotebookLM ${label} failed — underlying cause: ${e?.message || e}. Ensure Chrome tab is open and the page is loaded.`);\n}","preventionTips":["Keep the Chrome window open and the tab active during CLI operations","Avoid navigating or closing the tab while a command runs","Run with --verbose so the underlying transport error is visible"],"tags":["browser-bridge","transport","notebooklm"],"backgroundTag":"browser-automation-transport-failure","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}