jackwener/OpenCLI · error · CommandExecutionError

String(data.error)

Error message

String(data.error)

What it means

CommandExecutionError wrapping the raw error string returned inside the scrape result object (data.error). The playlist extraction succeeded structurally but reported a domain-specific failure — e.g. YouTube showed an error/alert box instead of playlist data — and the library surfaces that string verbatim.

Source

Thrown at clis/youtube/playlist.js:89

        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

  1. Check the error string — 'playlist unavailable' means the ID is wrong/private/deleted
  2. Verify the playlist opens in a normal browser
  3. Login to YouTube in the CLI profile if consent/age gating is indicated
  4. Update the CLI package to pick up extraction fixes for new YouTube markup

Example fix

// before
opencli youtube playlist PL_DELETED  // 'The playlist does not exist.'
// after
opencli youtube playlist PL_EXISTING_PUBLIC_ID
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
  const videos = await run('youtube playlist', [id]);
} catch (e) {
  if (/does not exist|unavailable|private/i.test(e.message)) {
    console.error(`Playlist ${id} is gone or private: ${e.message}`);
  } else throw e;
}

Prevention

When it happens

Trigger: The in-page script returns {error: '<description>'} — typically ytInitialData missing, a 'Playlist does not exist' / 'unavailable' alert, or a consent/bot-check page detected during extraction.

Common situations: Deleted or private playlist IDs, region-locked playlists, YouTube UI/ytInitialData schema changes breaking extraction, or age/consent interstitials in headless sessions.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/bd69dbe2ffca4643. Report an issue: GitHub.