{"record":{"id":"37949bf9cccecafb","repo":"jackwener/OpenCLI","slug":"failed-to-fetch-youtube-history","errorCode":null,"errorMessage":"Failed to fetch YouTube history","messagePattern":"Failed to fetch YouTube history","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youtube/history.js","lineNumber":267,"sourceCode":"\n        return {\n          error: 'page-cap',\n          message: 'YouTube history pagination stopped before satisfying the requested limit',\n        };\n      })()\n    `);\n\n        if (Array.isArray(result)) return result;\n        if (result?.error === 'auth') {\n            throw new AuthRequiredError('www.youtube.com', result.message || 'Not logged in to YouTube');\n        }\n        if (result?.error === 'timeout') {\n            throw new TimeoutError('YouTube history request', REQUEST_TIMEOUT_SECONDS);\n        }\n        if (result?.error === 'empty') {\n            throw new EmptyResultError('youtube history', result.message || 'No watch history items found');\n        }\n        throw new CommandExecutionError(result?.message || 'Failed to fetch YouTube history');\n    },\n});\n","sourceCodeStart":249,"sourceCodeEnd":270,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youtube/history.js#L249-L270","documentation":"CommandExecutionError thrown by the youtube history command when the in-page scrape finished but returned an unrecognized failure (any result.error other than 'timeout' or 'empty', or an error message string). It is the generic catch-all for a failed YouTube watch-history fetch. The library throws it because the scrape could not be classified as a timeout or an empty-result case.","triggerScenarios":"The page.evaluate scrape of the watch-history page returns {error: ...} with an unexpected code (e.g. 'http', 'nav', 'config'), or result is missing the expected fields; typically YouTube DOM changes, redirects to a consent/login page, or a non-200 response during scraping.","commonSituations":"YouTube layout updates breaking the scrape selectors, hitting a consent screen, account without watch history yet in an unexpected state, transient network failure mid-page-load, or a headless browser page rendered as a bot-check page.","solutions":["Re-run the command once — transient page-load failures are common","Verify you are logged into YouTube in the CLI's browser profile (history requires auth)","Clear stale cookies/consent state for www.youtube.com in the profile and retry","Update the CLI package so scrape selectors match the current YouTube DOM","Check stderr/output for the underlying result.message for the real cause"],"exampleFix":"// before\nopencli youtube history\n// after\nopencli youtube history --debug   # see underlying result.message; re-auth profile if needed","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"function isCommandFailure(r) { return r && typeof r === 'object' && 'error' in r; }","tryCatchPattern":"try {\n  const rows = await run('youtube history');\n} catch (e) {\n  if (/history/i.test(e.message)) {\n    console.error('History fetch failed:', e.message, '— check YouTube login and retry');\n  } else throw e;\n}","preventionTips":["Keep the CLI browser profile logged into YouTube","Retry transient failures before surfacing to users","Keep the package updated for YouTube DOM changes","Log the underlying result.message for diagnosis"],"tags":["youtube","scraping","command-execution"],"backgroundTag":"page-scrape-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}