{"record":{"id":"09857f732f0cbef2","repo":"jackwener/OpenCLI","slug":"youtube-video-metadata-is-missing-playabilitystatu","errorCode":null,"errorMessage":"YouTube video metadata is missing playabilityStatus","messagePattern":"YouTube video metadata is missing playabilityStatus","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youtube/video.js","lineNumber":24,"sourceCode":"import { CommandExecutionError } from '@jackwener/opencli/errors';\n\nfunction unwrapBrowserResult(value) {\n    if (value && typeof value === 'object' && 'session' in value && 'data' in value) {\n        return value.data;\n    }\n    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: [","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youtube/video.js#L6-L42","documentation":"CommandExecutionError thrown during schema validation of the extracted video payload: payload.playabilityStatus is not a string. The library treats the video metadata shape as a contract; a missing or wrongly-typed playabilityStatus means the page script produced a structurally invalid payload, so it refuses to continue rather than return unreliable data.","triggerScenarios":"The in-page extraction returned an object without a string playabilityStatus — e.g. YouTube changed the player response structure, or the script short-circuited on an unexpected page state.","commonSituations":"YouTube front-end updates renaming/moving playabilityStatus; extraction running on a non-watch page or consent interstitial; scripts grabbing ytcfg/player data before the player response is populated.","solutions":["Update the library/tooling to match the current YouTube player response schema.","Ensure the video watch page fully loaded (wait for player data/ytcfg) before extraction.","Log the raw payload to inspect what fields were actually extracted and compare with the expected schema.","Retry the extraction; if it consistently fails, the page structure likely changed and needs a code fix."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const payload = unwrapBrowserResult(raw);\nif (!payload || typeof payload.playabilityStatus !== 'string') {\n  throw new Error('Invalid video payload: playabilityStatus must be a string');\n}","typeGuard":"function hasPlayabilityStatus(p) {\n  return p != null && typeof p === 'object' && typeof p.playabilityStatus === 'string';\n}","tryCatchPattern":"try {\n  const info = await video(url);\n} catch (e) {\n  if (e.name === 'CommandExecutionError' && /playabilityStatus/.test(e.message)) {\n    console.error('YouTube payload schema changed');\n  }\n  throw e;\n}","preventionTips":["Wait for the player response/ytcfg to be populated before extracting metadata.","Log raw payloads when validation fails to spot YouTube schema drift early.","Pin/update the library when YouTube renames or relocates playabilityStatus.","Retry extraction once before concluding the page structure changed."],"tags":["youtube","schema-validation","metadata","type-mismatch"],"backgroundTag":"youtube-payload-schema-mismatch","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}