jackwener/OpenCLI · error · CommandExecutionError
Failed to fetch YouTube history
Error message
Failed to fetch YouTube history
What it means
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.
Source
Thrown at clis/youtube/history.js:267
return {
error: 'page-cap',
message: 'YouTube history pagination stopped before satisfying the requested limit',
};
})()
`);
if (Array.isArray(result)) return result;
if (result?.error === 'auth') {
throw new AuthRequiredError('www.youtube.com', result.message || 'Not logged in to YouTube');
}
if (result?.error === 'timeout') {
throw new TimeoutError('YouTube history request', REQUEST_TIMEOUT_SECONDS);
}
if (result?.error === 'empty') {
throw new EmptyResultError('youtube history', result.message || 'No watch history items found');
}
throw new CommandExecutionError(result?.message || 'Failed to fetch YouTube history');
},
});
View on GitHub (pinned to 49907e53dc)
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
Example fix
// before opencli youtube history // after opencli youtube history --debug # see underlying result.message; re-auth profile if needed
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
function isCommandFailure(r) { return r && typeof r === 'object' && 'error' in r; } Try / catch
try {
const rows = await run('youtube history');
} catch (e) {
if (/history/i.test(e.message)) {
console.error('History fetch failed:', e.message, '— check YouTube login and retry');
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/37949bf9cccecafb.
Report an issue: GitHub.