Skip to content

Commit ac794b8

Browse files
committed
fix: extract notebook ID from index 2, not index 0
The createNotebook RPC response format is [title, null, uuid, ...]. We were extracting from index 0 (the title string) instead of index 2 (the UUID). This caused all subsequent RPC calls to use the notebook title as the source-path instead of the UUID, which the API rejects with error code [5]. Also fixed listNotebooks to use the same correct index.
1 parent eb37117 commit ac794b8

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

lib/services/notebooklm/client.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,10 @@ export class NotebookLMClient {
177177
const items = resultArr[0] as unknown[][];
178178
for (const item of items) {
179179
if (!Array.isArray(item)) continue;
180-
// Notebook ID is at [0][0] or [0], title at [2]
181-
const idContainer = item[0];
182-
const id =
183-
Array.isArray(idContainer) && idContainer.length > 0
184-
? String(idContainer[0])
185-
: String(idContainer ?? '');
186-
const title = typeof item[2] === 'string' ? item[2] : '';
180+
// Response format per notebook: [title, null, notebookId, ...]
181+
// Index 0 = title string, Index 2 = UUID string
182+
const title = typeof item[0] === 'string' ? item[0] : '';
183+
const id = typeof item[2] === 'string' ? item[2] : '';
187184
if (id) {
188185
notebooks.push({ id, title });
189186
}
@@ -220,18 +217,16 @@ export class NotebookLMClient {
220217
);
221218
}
222219

223-
// Extract notebook ID — typically at [0] or [0][0]
224-
const idContainer = resultArr[0];
225-
const id =
226-
Array.isArray(idContainer) && idContainer.length > 0
227-
? String(idContainer[0])
228-
: String(idContainer ?? '');
220+
// Response format: [title, null, notebookId, ...]
221+
// Index 0 = title string, Index 2 = UUID string
229222
const notebookTitle =
230-
typeof resultArr[2] === 'string' ? resultArr[2] : title;
223+
typeof resultArr[0] === 'string' ? resultArr[0] : title;
224+
const id =
225+
typeof resultArr[2] === 'string' ? resultArr[2] : '';
231226

232227
if (!id) {
233228
throw new NotebookLMRPCError(
234-
'No notebook ID returned from createNotebook',
229+
'No notebook ID returned from createNotebook — expected UUID at index 2',
235230
{ methodId: RPCMethod.CREATE_NOTEBOOK }
236231
);
237232
}

0 commit comments

Comments
 (0)