jackwener/OpenCLI · error · CommandExecutionError
Failed to fetch playlist data
Error message
Failed to fetch playlist data
What it means
CommandExecutionError thrown when the youtube playlist scrape's page.evaluate returns nothing usable — data is null, undefined, or not an object — meaning the in-page extraction script failed to produce its result object rather than returning a structured error. The library throws it instead of crashing on undefined property access.
Source
Thrown at clis/youtube/playlist.js:86
let videos = extractVideos(listContents);
let contItem = listContents[listContents.length - 1];
while (videos.length < limit && contItem?.continuationItemRenderer) {
const token = contItem.continuationItemRenderer?.continuationEndpoint?.continuationCommand?.token;
if (!token) break;
const contData = await fetchBrowse(apiKey, { context, continuation: token });
if (contData.error) break;
const newItems = contData.onResponseReceivedActions?.[0]?.appendContinuationItemsAction?.continuationItems || [];
if (!newItems.length) break;
videos = videos.concat(extractVideos(newItems));
contItem = newItems[newItems.length - 1];
}
return { title, channelName, stats, videos: videos.slice(0, limit) };
})()
`);
if (!data || typeof data !== 'object') {
throw new CommandExecutionError('Failed to fetch playlist data');
}
if (data.error) {
throw new CommandExecutionError(String(data.error));
}
if (!data.videos?.length) {
throw new EmptyResultError('youtube playlist');
}
const statsStr = (data.stats || []).join(' | ');
process.stderr.write(`${data.title} [${data.channelName}] ${statsStr}\n`);
return data.videos;
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the playlist URL/ID is valid, public, and still exists
- Re-run — transient page-load failures are common
- Log into YouTube in the profile to bypass consent walls
- Update the CLI if YouTube's page structure changed
Example fix
// before opencli youtube playlist PL_BAD_ID // null data // after opencli youtube playlist PL_VALID_PUBLIC_ID
Defensive patterns
Strategy: validation
Validate before calling
// ensure the playlist exists/public before scraping
const res = await fetch(`https://www.youtube.com/playlist?list=${id}`, { method: 'HEAD' });
if (!res.ok) throw new Error(`Playlist ${id} unreachable (HTTP ${res.status})`); Type guard
const isScrapeResult = (d) => d !== null && typeof d === 'object' && !Array.isArray(d);
Try / catch
try {
const videos = await run('youtube playlist', [id]);
} catch (e) {
if (/Failed to fetch playlist data/i.test(e.message)) {
console.error('Scrape returned no data — verify the playlist ID and login state');
} else throw e;
} Prevention
- Validate playlist IDs (start with PL, UU, etc.) before calling
- Test playlist visibility in a normal browser
- Retry once on transient failures
- Keep profile logged in to avoid consent/bot walls
- Update the CLI when YouTube markup changes
When it happens
Trigger: page.evaluate returns null/undefined/non-object: the playlist page failed to load, ytInitialData was absent, the script threw before returning and the harness swallowed it, or navigation hit a bot-check/consent page.
Common situations: Invalid or deleted playlist ID, private playlist, YouTube consent/cookie wall in a fresh profile, anti-bot interstitial, or network failure during page load.
Related errors
- String(data.error)
- String(data.error)
- errMsg
- Failed to fetch YouTube feed
- Failed to fetch YouTube history
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/43b4059ff7a8524a.
Report an issue: GitHub.