{"record":{"id":"78b0004164595985","repo":"jackwener/OpenCLI","slug":"failed-to-like-video","errorCode":null,"errorMessage":"Failed to like video","messagePattern":"Failed to like video","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youtube/like.js","lineNumber":63,"sourceCode":"          },\n          body: JSON.stringify({ context, target: { videoId: ${JSON.stringify(videoId)} } }),\n        });\n\n        if (resp.status === 401 || resp.status === 403) return { error: 'auth', message: 'Not logged in' };\n        if (!resp.ok) {\n          const body = await resp.json().catch(() => ({}));\n          const errStatus = body?.error?.status || '';\n          if (errStatus === 'UNAUTHENTICATED') return { error: 'auth', message: 'Not logged in' };\n          return { error: 'http', message: 'HTTP ' + resp.status + (errStatus ? ' ' + errStatus : '') };\n        }\n        return { ok: true };\n      })()\n    `);\n        if (result?.error === 'auth') {\n            throw new AuthRequiredError('www.youtube.com');\n        }\n        if (result?.error) {\n            throw new CommandExecutionError(result.message || 'Failed to like video');\n        }\n        return [{ status: 'success', message: 'Liked: ' + videoId }];\n    },\n});\n","sourceCodeStart":45,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youtube/like.js#L45-L68","documentation":"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.","triggerScenarios":"/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.","commonSituations":"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.","solutions":["Read the actual result.message (e.g. 'HTTP 400 ...') to identify the real cause","Wait and retry if the status is 429 (rate limited)","Confirm the video is likeable (public, not live-disabled-likes, region available)","Reload/re-navigate youtube.com in the profile to restore ytcfg, then retry","Update the CLI if YouTube changed its InnerTube config surface"],"exampleFix":"// before\nopencli youtube like VIDEO_ID  // HTTP 429 rate limited\n// after\nsleep 60 && opencli youtube like VIDEO_ID","handlingStrategy":"try-catch","validationCode":"// pre-validate the video id format\nconst id = url.match(/(?:v=|youtu\\.be\\/|shorts\\/)([\\w-]{11})/)?.[1];\nif (!id) throw new Error('Invalid YouTube URL/id');","typeGuard":"const isValidVideoId = (s) => /^[\\w-]{11}$/.test(s);","tryCatchPattern":"try {\n  await run('youtube like', [url]);\n} catch (e) {\n  const m = /HTTP (\\d+)/.exec(e.message);\n  if (m && m[1] === '429') { await sleep(60000); return retry(); }\n  console.error('Like failed:', e.message); // includes real HTTP/API status\n}","preventionTips":["Read result.message — it embeds the real HTTP status and API error","Back off on 429 rate-limit responses","Confirm videos are public and likes are enabled before automating","Reload youtube.com in the profile if ytcfg/config errors appear","Keep the CLI updated against InnerTube changes"],"tags":["youtube","api","command-execution","innertube"],"backgroundTag":"api-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}