jackwener/OpenCLI · warning · EmptyResultError

youtube watch-later

Error message

youtube watch-later

What it means

An EmptyResultError with the command name 'youtube watch-later' as its message, thrown when the Watch Later fetch succeeded (authenticated, no error field) but the parsed `videos` array is empty or missing. The library treats a logged-in-but-zero-videos playlist as a distinct condition so callers can handle 'no data' separately from auth or extraction failures.

Source

Thrown at clis/youtube/watch-later.js:71

          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, stats, videos: videos.slice(0, limit) };
      })()
    `);
        if (!data || typeof data !== 'object') {
            throw new CommandExecutionError('Failed to fetch Watch Later — make sure you are logged into YouTube');
        }
        if (data.error) {
            throw new CommandExecutionError(String(data.error));
        }
        if (!data.videos?.length) {
            throw new EmptyResultError('youtube watch-later');
        }
        const statsStr = (data.stats || []).join(' | ');
        process.stderr.write(`${data.title}  ${statsStr}\n`);
        return data.videos;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Confirm in a browser that the account's Watch Later list actually has videos.
  2. Add videos to Watch Later if the list is legitimately empty.
  3. If videos exist in the browser but the CLI returns this, update the CLI — the selector likely no longer matches.
  4. Catch EmptyResultError explicitly in scripts to treat it as 'no data' rather than a hard failure.

Example fix

// before
const videos = await cli.run(['youtube', 'watch-later']);
// after
try {
  const videos = await cli.run(['youtube', 'watch-later']);
} catch (e) {
  if (e instanceof EmptyResultError) return [];
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Cannot validate remotely beforehand; guard the consumer instead
const safeVideos = Array.isArray(videos) ? videos : [];

Type guard

const isNonEmptyList = (v) => Array.isArray(v) && v.length > 0;

Try / catch

try {
  const videos = await run(['youtube', 'watch-later']);
} catch (e) {
  if (e.name === 'EmptyResultError' || e.message === 'youtube watch-later') return [];
  throw e;
}

Prevention

When it happens

Trigger: Running `youtube watch-later` (with or without --limit) when the authenticated session's Watch Later list is genuinely empty, or when the extraction found the page but its video-selector matched nothing due to a layout change.

Common situations: A fresh account with nothing saved to Watch Later; user recently cleared their Watch Later list; YouTube DOM change breaking the video selector so all rows are missed.

Related errors


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