{"record":{"id":"d0531341a9783fdb","repo":"jackwener/OpenCLI","slug":"youtube-video-metadata-is-missing-membersonly","errorCode":null,"errorMessage":"YouTube video metadata is missing membersOnly","messagePattern":"YouTube video metadata is missing membersOnly","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youtube/video.js","lineNumber":30,"sourceCode":"    return value;\n}\n\nfunction requireVideoPayload(value) {\n    const payload = unwrapBrowserResult(value);\n    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n        throw new CommandExecutionError('Failed to extract video metadata from page');\n    }\n    if (payload.error) {\n        throw new CommandExecutionError(String(payload.error));\n    }\n    if (typeof payload.playabilityStatus !== 'string') {\n        throw new CommandExecutionError('YouTube video metadata is missing playabilityStatus');\n    }\n    if (typeof payload.playabilityReason !== 'string') {\n        throw new CommandExecutionError('YouTube video metadata is missing playabilityReason');\n    }\n    if (typeof payload.membersOnly !== 'boolean') {\n        throw new CommandExecutionError('YouTube video metadata is missing membersOnly');\n    }\n    return payload;\n}\n\ncli({\n    site: 'youtube',\n    name: 'video',\n    access: 'read',\n    description: 'Get YouTube video metadata (title, views, description, etc.)',\n    domain: 'www.youtube.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'url', required: true, positional: true, help: 'YouTube video URL or video ID' },\n    ],\n    columns: ['field', 'value'],\n    func: async (page, kwargs) => {\n        const videoId = parseVideoId(kwargs.url);\n        await prepareYoutubeApiPage(page);","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youtube/video.js#L12-L48","documentation":"This CommandExecutionError is thrown by requireVideoPayload in clis/youtube/video.js when the scraped YouTube watch-page bootstrap data does not contain a boolean `membersOnly` field. The library validates that the page extraction returned all expected metadata keys (playabilityStatus, playabilityReason, membersOnly); if YouTube's page structure changed, or the extraction produced a partial object, the guard fires so callers never receive incomplete metadata. It indicates a parse/extraction failure rather than a problem with the requested video itself.","triggerScenarios":"Calling the `youtube video <url>` CLI command when the in-page extraction script returns an object lacking a boolean membersOnly field — typically after a YouTube page markup change, a truncated/consented page render, or a bot-checked page whose ytInitialPlayerResponse differs from the expected shape.","commonSituations":"YouTube A/B tests or redesigns altering the bootstrap player response; scraping from a datacenter IP that receives a consent or captcha page; stale session cookies yielding a degraded page; the CLI version lagging behind a site change.","solutions":["Update the opencli package to the latest version so the extractor matches current YouTube markup.","Re-run with fresh/valid YouTube cookies (re-login) to rule out consent or bot-check pages serving a degraded page.","Inspect the raw page payload by temporarily logging the extraction result to confirm which fields are missing.","If it persists, report the issue — the extractor likely needs updating for a YouTube markup change."],"exampleFix":"// before\nif (typeof payload.membersOnly !== 'boolean') {\n    throw new CommandExecutionError('YouTube video metadata is missing membersOnly');\n}\n// after\nif (payload.membersOnly === undefined) {\n    payload.membersOnly = payload.playabilityStatus === 'UNPLAYABLE' && /members[- ]only/i.test(payload.playabilityReason || '');\n}","handlingStrategy":"validation","validationCode":"function isValidVideoPayload(p) {\n  return !!p && typeof p === 'object' && !Array.isArray(p)\n    && typeof p.playabilityStatus === 'string'\n    && typeof p.playabilityReason === 'string'\n    && typeof p.membersOnly === 'boolean';\n}","typeGuard":"const isVideoPayload = (p) =>\n  typeof p === 'object' && p !== null && !Array.isArray(p) &&\n  typeof p.membersOnly === 'boolean';","tryCatchPattern":"try {\n  const meta = await runYoutubeVideo(url);\n} catch (e) {\n  if (/missing membersOnly/.test(e.message)) {\n    // extraction shape failure: retry once, then surface as site-change issue\n  } else throw e;\n}","preventionTips":["Keep the CLI updated since YouTube markup changes break extractors","Use a logged-in, clean session to avoid consent/captcha pages degrading the payload","Validate the payload shape before consuming fields","Log the raw payload when this error occurs to aid reporting"],"tags":["youtube","scraping","schema-mismatch","parsing"],"backgroundTag":"page-schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}