{"record":{"id":"8ccbe796a7c473ac","repo":"jackwener/OpenCLI","slug":"notebooklm-current-page-probe-returned-malformed-b","errorCode":null,"errorMessage":"NotebookLM current-page probe returned malformed Browser Bridge data","messagePattern":"NotebookLM current-page probe returned malformed Browser Bridge data","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/utils.js","lineNumber":728,"sourceCode":"export async function readCurrentNotebooklm(page) {\n    const raw = await evaluateNotebooklm(page, `(() => {\n    const url = window.location.href;\n    const match = url.match(/\\\\/notebook\\\\/([^/?#]+)/);\n    if (!match) return null;\n\n    const titleNode = document.querySelector('h1, [data-testid=\"notebook-title\"], [role=\"heading\"]');\n    const title = (titleNode?.textContent || document.title || '').trim();\n    return {\n      id: match[1],\n      title,\n      url,\n      source: 'current-page',\n    };\n  })()`, 'current-page probe');\n    if (!raw)\n        return null;\n    if (!isPlainObject(raw) || typeof raw.id !== 'string' || typeof raw.title !== 'string' || typeof raw.url !== 'string') {\n        throw new CommandExecutionError('NotebookLM current-page probe returned malformed Browser Bridge data');\n    }\n    const url = normalizeNotebooklmNotebookUrl(raw.url, raw.id);\n    if (!url) {\n        throw new CommandExecutionError('NotebookLM current-page probe returned an untrusted or mismatched notebook URL');\n    }\n    return {\n        id: raw.id,\n        title: normalizeNotebooklmTitle(raw.title, 'Untitled Notebook'),\n        url,\n        source: 'current-page',\n        is_owner: true,\n        created_at: null,\n    };\n}\nexport async function listNotebooklmLinks(page) {\n    const raw = await evaluateNotebooklm(page, `(() => {\n    const rows = [];\n    const seen = new Set();","sourceCodeStart":710,"sourceCodeEnd":746,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/utils.js#L710-L746","documentation":"The current-page probe runs an in-page script via Browser Bridge to identify the active NotebookLM notebook. It expects the evaluated result to be a plain object with string id, title, and url fields. If the bridge returns null-primitive, non-object, or missing/incorrectly-typed fields, this CommandExecutionError is thrown instead of trusting unverified page data.","triggerScenarios":"The injected probe script in the active tab returns something other than {id:string,title:string,url:string} — e.g. the evaluated snippet returns undefined, a JSON-parse failure wrapped object, or the page DOM changed so the selectors yield missing fields.","commonSituations":"The active Chrome tab is not a NotebookLM notebook page, the Browser Bridge extension/injection failed silently, a NotebookLM UI update changed the DOM the probe scrapes, or the probe ran before the SPA finished rendering.","solutions":["Ensure the active Chrome tab is a loaded NotebookLM notebook page (URL matching the NotebookLM notebook pattern) before running the command.","Re-run the command after the page fully loads; SPA hydration may not have completed on first attempt.","Update the NotebookLM CLI and Browser Bridge extension to the latest versions to match current NotebookLM DOM.","Verify the Browser Bridge connection (extension enabled, correct port/debug target) — a dead bridge often returns a malformed empty payload."],"exampleFix":"// before: assuming probe always returns an object\nconst page = await probeCurrentPage();\nconsole.log(page.id);\n\n// after: guard and recover\nlet page = null;\ntry {\n  page = await probeCurrentPage();\n} catch (e) {\n  if (String(e.message).includes('malformed Browser Bridge data')) {\n    console.error('Open a NotebookLM notebook tab in Chrome and retry.');\n  } else throw e;\n}","handlingStrategy":"type-guard","validationCode":"function looksLikePageProbe(v) {\n  return v !== null && typeof v === 'object' &&\n    typeof v.id === 'string' && v.id.length > 0 &&\n    typeof v.title === 'string' &&\n    typeof v.url === 'string' && v.url.startsWith('https://notebooklm.google.com/');\n}","typeGuard":"const isPlainPageState = (v) => Object.prototype.toString.call(v) === '[object Object]' && typeof v.id === 'string' && typeof v.title === 'string' && typeof v.url === 'string';","tryCatchPattern":"try {\n  const page = await probeCurrentPage();\n} catch (e) {\n  if (String(e.message).includes('malformed Browser Bridge data')) {\n    console.error('Active tab is not a loaded NotebookLM notebook; open one and retry.');\n  } else { throw e; }\n}","preventionTips":["Always focus a fully loaded NotebookLM notebook tab before running probe commands.","Keep the Browser Bridge extension and CLI versions in sync.","Retry once after a short delay to allow SPA rendering to finish.","Log raw probe output during development to catch DOM changes early."],"tags":["browser-bridge","notebooklm","schema-validation-failed","probe"],"backgroundTag":"browser-bridge-malformed-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}