jackwener/OpenCLI · error · CommandExecutionError

Failed to like video

Error message

Failed to like video

What it means

CommandExecutionError fallback for any like-request failure that is neither auth-related nor a success — typically the InnerTube endpoint returned a non-2xx status other than 401/403 (HTTP status and API error status are carried in result.message) or YouTube's page config (INNERTUBE_API_KEY/CONTEXT) was missing. The literal 'Failed to like video' appears when result.message is empty.

Source

Thrown at clis/youtube/like.js:63

          },
          body: JSON.stringify({ context, target: { videoId: ${JSON.stringify(videoId)} } }),
        });

        if (resp.status === 401 || resp.status === 403) return { error: 'auth', message: 'Not logged in' };
        if (!resp.ok) {
          const body = await resp.json().catch(() => ({}));
          const errStatus = body?.error?.status || '';
          if (errStatus === 'UNAUTHENTICATED') return { error: 'auth', message: 'Not logged in' };
          return { error: 'http', message: 'HTTP ' + resp.status + (errStatus ? ' ' + errStatus : '') };
        }
        return { ok: true };
      })()
    `);
        if (result?.error === 'auth') {
            throw new AuthRequiredError('www.youtube.com');
        }
        if (result?.error) {
            throw new CommandExecutionError(result.message || 'Failed to like video');
        }
        return [{ status: 'success', message: 'Liked: ' + videoId }];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the actual result.message (e.g. 'HTTP 400 ...') to identify the real cause
  2. Wait and retry if the status is 429 (rate limited)
  3. Confirm the video is likeable (public, not live-disabled-likes, region available)
  4. Reload/re-navigate youtube.com in the profile to restore ytcfg, then retry
  5. Update the CLI if YouTube changed its InnerTube config surface

Example fix

// before
opencli youtube like VIDEO_ID  // HTTP 429 rate limited
// after
sleep 60 && opencli youtube like VIDEO_ID
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-validate the video id format
const id = url.match(/(?:v=|youtu\.be\/|shorts\/)([\w-]{11})/)?.[1];
if (!id) throw new Error('Invalid YouTube URL/id');

Type guard

const isValidVideoId = (s) => /^[\w-]{11}$/.test(s);

Try / catch

try {
  await run('youtube like', [url]);
} catch (e) {
  const m = /HTTP (\d+)/.exec(e.message);
  if (m && m[1] === '429') { await sleep(60000); return retry(); }
  console.error('Like failed:', e.message); // includes real HTTP/API status
}

Prevention

When it happens

Trigger: /youtubei/v1/like/like returns e.g. HTTP 400/429/5xx, returns {error:'config'} because window.ytcfg lacked INNERTUBE_API_KEY or INNERTUBE_CONTEXT, or a malformed result object with no message.

Common situations: Rate limiting after liking many videos quickly, video disabled likes or region-blocked, YouTube InnerTube config changes / anti-bot interstitial replacing the page, or unliked-then-reliked race conditions server-side.

Related errors


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