{"record":{"id":"a40d1f558913e230","repo":"jackwener/OpenCLI","slug":"notebooklm-page-auth-probe-returned-an-invalid-pat","errorCode":null,"errorMessage":"NotebookLM page auth probe returned an invalid path or authuser","messagePattern":"NotebookLM page auth probe returned an invalid path or authuser","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/rpc.js","lineNumber":67,"sourceCode":"      sessionId: typeof wiz.FdrFJe === 'string' ? wiz.FdrFJe : '',\n      authuser: authMatch ? authMatch[1] : (pathMatch ? pathMatch[1] : ''),\n      url: location.href,\n    };\n  })()`);\n    }\n    catch (error) {\n        rethrowNotebooklmTransport(error, 'page auth probe');\n    }\n    const raw = requireNotebooklmObject(unwrapNotebooklmEvaluateResult(evaluated), 'page auth probe');\n    const pageUrl = parseTrustedNotebooklmUrl(raw.url);\n    if (!pageUrl) {\n        throw new CommandExecutionError('NotebookLM page auth probe is not on a trusted HTTPS NotebookLM origin');\n    }\n    if (typeof raw.html !== 'string' || typeof raw.sourcePath !== 'string' || typeof raw.csrfToken !== 'string' || typeof raw.sessionId !== 'string' || typeof raw.authuser !== 'string') {\n        throw new CommandExecutionError('NotebookLM page auth probe returned malformed fields');\n    }\n    if (raw.sourcePath !== pageUrl.pathname || (raw.authuser && !/^\\d+$/.test(raw.authuser))) {\n        throw new CommandExecutionError('NotebookLM page auth probe returned an invalid path or authuser');\n    }\n    return {\n        html: raw.html,\n        sourcePath: raw.sourcePath,\n        readyState: typeof raw.readyState === 'string' ? raw.readyState : '',\n        csrfToken: raw.csrfToken,\n        sessionId: raw.sessionId,\n        authuser: raw.authuser,\n        origin: pageUrl.origin,\n    };\n}\nexport async function getNotebooklmPageAuth(page) {\n    let lastError;\n    for (let attempt = 0; attempt < 2; attempt += 1) {\n        const probe = await probeNotebooklmPageAuth(page);\n        try {\n            return {\n                ...extractNotebooklmPageAuthFromHtml(probe.html, probe.sourcePath, { csrfToken: probe.csrfToken, sessionId: probe.sessionId, authuser: probe.authuser }),","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/rpc.js#L49-L85","documentation":"This is the probe's consistency check: the reported sourcePath must equal the pathname of the already-validated trusted page URL, and authuser, when non-empty, must be all digits. A mismatch means the evaluated payload does not actually correspond to the page the browser is on, so probeNotebooklmPageAuth throws this CommandExecutionError rather than return credentials for the wrong context.","triggerScenarios":"probe() evaluates while a client-side redirect/navigation happens mid-probe (sourcePath from an older page vs pageUrl from the new URL), or the page sets authuser to a non-numeric value like '0@default' or a debug string.","commonSituations":"NotebookLM navigated between notebook views while the probe ran (race); a custom multi-account authuser parameter format changed; an extension injected a wrapper page altering location.pathname reporting.","solutions":["Re-run the probe — a mid-navigation race usually resolves on a stable, fully loaded page","Wait for network idle on the notebook page before invoking the command","Pass the numeric authuser explicitly via CLI flags so the expected value matches the page","Disable extensions that rewrite navigation/URLs and retry"],"exampleFix":"// before (probing during navigation)\nawait page.click('.notebook-link');\nconst auth = await probeNotebooklmPageAuth(page);\n// after (wait for navigation to settle)\nawait Promise.all([page.waitForNavigation({ waitUntil: 'networkidle' }), page.click('.notebook-link')]);\nconst auth = await probeNotebooklmPageAuth(page);","handlingStrategy":"retry","validationCode":"const pageUrl = new URL(page.url());\nif (await page.evaluate(() => document.readyState) !== 'complete') {\n  await page.waitForNavigation({ waitUntil: 'networkidle' }).catch(() => {});\n}","typeGuard":"function probePathMatches(raw, pageUrl) {\n  return typeof raw.sourcePath === 'string' && raw.sourcePath === pageUrl.pathname &&\n    (!raw.authuser || /^\\d+$/.test(raw.authuser));\n}","tryCatchPattern":"try {\n  auth = await probeNotebooklmPageAuth(page);\n} catch (e) {\n  if (/invalid path or authuser/.test(e.message)) {\n    await sleep(1500); // navigation race: retry once on a stable page\n    auth = await probeNotebooklmPageAuth(page);\n  } else throw e;\n}","preventionTips":["Do not navigate or click in the notebook while a CLI command runs","Wait for the page to settle (network idle) before invoking commands","Pass a numeric --authuser explicitly to keep expected and actual values aligned"],"tags":["validation","race-condition","auth","notebooklm"],"backgroundTag":"payload-consistency-check-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}