jackwener/OpenCLI · error · CommandExecutionError

errMsg

Error message

errMsg

What it means

CommandExecutionError raised by `youtube comments` when the in-page script returns a non-array object carrying an `error` field. The library extracts data.error into errMsg and throws it, signaling the comments scrape failed instead of returning an empty list. If the object has no error string the command silently returns [] instead.

Source

Thrown at clis/youtube/comments.js:91

          const p = m.payload.commentEntityPayload;
          const props = p.properties || {};
          const author = p.author || {};
          const toolbar = p.toolbar || {};
          return {
            rank: i + 1,
            author: author.displayName || '',
            text: (props.content?.content || '').substring(0, 300),
            likes: toolbar.likeCountNotliked || '0',
            replies: toolbar.replyCount || '0',
            time: props.publishedTime || '',
          };
        });
      })()
    `);
        if (!Array.isArray(data)) {
            const errMsg = data && typeof data === 'object' ? String(data.error || '') : '';
            if (errMsg)
                throw new CommandExecutionError(errMsg);
            return [];
        }
        return data;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect the forwarded errMsg — it names the page-side cause (auth, disabled comments, etc.).
  2. Verify the video ID is valid and its comments are enabled.
  3. Ensure cookies/login state is present if the error indicates auth.
  4. Slow down request rate or retry later; if it persists for all videos, update the library after a YouTube change.
Defensive patterns

Strategy: try-catch

Validate before calling

if (!videoId || !/^[\w-]{11}$/.test(videoId)) throw new Error('invalid video id');

Type guard

function isCommentArray(d) {
  return Array.isArray(d);
}
function pageError(d) {
  return d && typeof d === 'object' && d.error ? String(d.error) : null;
}

Try / catch

try {
  const comments = await yt.comments(videoId);
} catch (e) {
  if (e instanceof CommandExecutionError) {
    console.error(`comments fetch failed: ${e.message}`);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `youtube comments` when the embedded evaluate script returns {error: '...'} instead of an array of comments — typically YouTube rejecting the request (auth/consent, video unavailable, comments disabled, rate limiting) or a DOM/API change causing an in-script exception.

Common situations: Fetching comments on a video with comments disabled; scraping a removed/private video while logged out; hitting YouTube rate limits after many rapid requests; YouTube markup change breaking the extractor for all videos.

Related errors


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