{"record":{"id":"065acbf92d8ef441","repo":"jackwener/OpenCLI","slug":"not-found-065acb","errorCode":"NOT_FOUND","errorMessage":"No chapters found for this book","messagePattern":"No chapters found for this book","errorType":"exception","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/weread/ai-outline.js","lineNumber":99,"sourceCode":"    defaultFormat: 'plain',\n    args: [\n        { name: 'book-id', positional: true, required: true, help: 'Book ID (from shelf or search results)' },\n        { name: 'limit', type: 'int', default: 200, help: 'Max outline items to return' },\n        { name: 'depth', type: 'int', default: 4, help: 'Max outline depth (2=topics, 3=key points, 4=details)' },\n        { name: 'raw', type: 'boolean', default: false, help: 'Output structured rows (chapter/idx/level/text) for programmatic use' },\n    ],\n    columns: undefined,\n    func: async (page, args) => {\n        const bookId = String(args['book-id'] || '').trim();\n        const rawMode = Boolean(args.raw);\n\n        const chapterData = await postWebApiWithCookies(page, '/book/chapterInfos', {\n            bookIds: [bookId],\n            sinces: [0],\n        });\n        const chapters = chapterData?.data?.[0]?.updated ?? [];\n        if (chapters.length === 0) {\n            throw new CliError('NOT_FOUND', 'No chapters found for this book', 'Check that the book ID is correct');\n        }\n\n        const chapterUids = chapters.map((c) => c.chapterUid);\n        const chapterNameMap = new Map();\n        for (const c of chapters) {\n            chapterNameMap.set(c.chapterUid, c.title ?? '');\n        }\n\n        const outlineData = await postWebApi('/book/outline', {\n            bookId,\n            chapterUids,\n        });\n\n        const itemsArray = outlineData?.itemsArray ?? [];\n        const maxDepth = Number(args.depth);\n        const rawRows = [];\n\n        for (const entry of itemsArray) {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weread/ai-outline.js#L81-L117","documentation":"The ai-outline command in clis/weread/ai-outline.js throws CliError('NOT_FOUND') when the /book/chapterInfos API returns no chapters (chapterData?.data?.[0]?.updated is empty) for the given bookId. The library uses this to signal that the book ID is unusable rather than a network or auth problem.","triggerScenarios":"Calling `ai-outline <book-id>` where POST /web/book/chapterInfos with {bookIds:[bookId], sinces:[0]} returns data[0].updated as an empty array or undefined — wrong/malformed bookId, a book with no chapter list, or restricted/foreign-region books.","commonSituations":"Passing a search-result ID from a different site, a truncated or quoted bookId, using an ID of a book that exists but whose chapter infos require entitlement, or a book that is unpublished/removed.","solutions":["Verify the book ID is correct — copy it again from the WeRead book page URL (weread.qq.com/web/reader/<id>) or from `weread shelf`/search output.","Confirm the book is accessible in your logged-in WeRead account (some books are region/login restricted).","Check chapterData by fetching the book page in a browser to confirm chapters exist.","Try a different known-good bookId to rule out an account/session-specific empty response."],"exampleFix":"// before\nweread ai-outline 'wr_1234x'   // typo'd id -> NOT_FOUND\n// after\nweread ai-outline '3300027746' // correct id from book page URL","handlingStrategy":"validation","validationCode":"const bookId = String(rawBookId || '').trim();\nif (!bookId || !/^\\d+$|^[A-Za-z0-9_-]+$/.test(bookId)) throw new Error(`Suspicious bookId: ${rawBookId}`);","typeGuard":null,"tryCatchPattern":"try { await aiOutline(bookId); } catch (e) {\n  if (e.code === 'NOT_FOUND') console.error(`Book ${bookId} has no chapters — verify the ID from the book page URL`);\n  else throw e;\n}","preventionTips":["Copy bookId directly from the weread.qq.com book page URL","Sanity-check the ID against `weread search` output before calling","Test with a known-good bookId to separate bad-input from session issues"],"tags":["not-found","weread","input-validation"],"backgroundTag":"resource-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}