{"record":{"id":"19fa7907482cdade","repo":"jackwener/OpenCLI","slug":"notebooklm-rpc-schema","errorCode":"NOTEBOOKLM_RPC_SCHEMA","errorMessage":"NotebookLM RPC ${rpcId} returned malformed JSON","messagePattern":"NotebookLM RPC (.+?) returned malformed JSON","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/rpc.js","lineNumber":169,"sourceCode":"            if (item[0] === 'er') {\n                const errorCode = typeof item[2] === 'number'\n                    ? item[2]\n                    : typeof item[5] === 'number'\n                        ? item[5]\n                        : null;\n                if (errorCode === 401 || errorCode === 403) {\n                    throw new AuthRequiredError(NOTEBOOKLM_DOMAIN, `NotebookLM RPC returned auth error (${errorCode})`);\n                }\n                throw new CliError('NOTEBOOKLM_RPC', `NotebookLM RPC failed${errorCode ? ` (code=${errorCode})` : ''}`, 'Retry from an already logged-in NotebookLM session, or inspect the raw response with debug logging.');\n            }\n            if (item[0] === 'wrb.fr' && item[1] === rpcId) {\n                const payload = item[2];\n                if (typeof payload === 'string') {\n                    try {\n                        return JSON.parse(payload);\n                    }\n                    catch {\n                        throw new CliError('NOTEBOOKLM_RPC_SCHEMA', `NotebookLM RPC ${rpcId} returned malformed JSON`, 'Retry from the NotebookLM page; the internal RPC response shape may have changed.');\n                    }\n                }\n                return payload;\n            }\n        }\n    }\n    throw new CliError('NOTEBOOKLM_RPC_SCHEMA', `NotebookLM RPC ${rpcId} returned no matching response frame`, 'Retry from the NotebookLM page; the internal RPC response shape may have changed.');\n}\nexport async function fetchNotebooklmInPage(page, url, options = {}) {\n    const method = options.method ?? 'GET';\n    const headers = options.headers ?? {};\n    const body = options.body ?? '';\n    let evaluated;\n    try {\n        evaluated = await page.evaluate(`(async () => {\n    const request = {\n      url: ${JSON.stringify(url)},\n      method: ${JSON.stringify(method)},","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/rpc.js#L151-L187","documentation":"When the matching 'wrb.fr' frame for the requested rpcId is found, its payload is expected to be a JSON string (or already-parsed value). If JSON.parse of the string payload throws, the library raises CliError code NOTEBOOKLM_RPC_SCHEMA indicating the response body is not parseable JSON — the internal response shape or encoding changed. This is a contract violation between the page's RPC layer and the CLI's parser.","triggerScenarios":"extractNotebooklmRpcResult finds item[0]==='wrb.fr' && item[1]===rpcId, payload is a string, but JSON.parse(payload) throws — truncated response, HTML error page embedded as payload, or a serialization change in the frame.","commonSituations":"Response truncated by a proxy or flaky network; Google served an HTML error/interstitial inside the frame; NotebookLM frontend update changed payload encoding; character-set issues mangling the JSON.","solutions":["Retry from a stable connection — truncation/corruption is often transient","Enable debug logging to capture the raw payload and see why it fails to parse","Update the CLI if NotebookLM changed its internal response encoding","Check proxies/VPN that might rewrite or truncate response bodies"],"exampleFix":"// before (parsing without protection)\nconst data = JSON.parse(payload);\n// after (tolerant parse)\nlet data;\ntry { data = JSON.parse(payload); } catch { throw new Error('malformed rpc payload: ' + payload.slice(0, 80)); }","handlingStrategy":"retry","validationCode":"// retry only parse failures; bail on others\nconst result = await withRetry(3, () => callNotebooklmRpc(page, rpcId, payload),\n  e => e.code === 'NOTEBOOKLM_RPC_SCHEMA');","typeGuard":"function isSchemaParseError(e) {\n  return e instanceof Error && e.code === 'NOTEBOOKLM_RPC_SCHEMA' && /malformed JSON/.test(e.message);\n}","tryCatchPattern":"try {\n  data = await callNotebooklmRpc(page, rpcId, payload);\n} catch (e) {\n  if (isSchemaParseError(e)) {\n    console.error('Malformed JSON from RPC — check network/proxy truncation and CLI version.');\n  } else throw e;\n}","preventionTips":["Use a stable connection; avoid proxies that truncate/rewrite responses","Retry once on parse failures — truncation is often transient","Update the CLI when the error recurs, as encoding changes accompany frontend updates"],"tags":["rpc","json","schema","notebooklm"],"backgroundTag":"rpc-malformed-json","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}