{"record":{"id":"de2647acd33c1b15","repo":"jackwener/OpenCLI","slug":"youtube-video-metadata-is-missing-playabilityreaso","errorCode":null,"errorMessage":"YouTube video metadata is missing playabilityReason","messagePattern":"YouTube video metadata is missing playabilityReason","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youtube/video.js","lineNumber":27,"sourceCode":"    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: [\n        { name: 'url', required: true, positional: true, help: 'YouTube video URL or video ID' },\n    ],\n    columns: ['field', 'value'],","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youtube/video.js#L9-L45","documentation":"CommandExecutionError thrown during schema validation of the extracted video payload: payload.playabilityReason is not a string. Like the playabilityStatus check, this enforces the metadata contract — the library expects both a playability status and a human-readable reason string, and throws when the reason field is missing or mistyped.","triggerScenarios":"The in-page extraction returned an object where playabilityReason is undefined or non-string — e.g. the page script did not populate the reason (no error reason available) or YouTube changed the field location in the player response.","commonSituations":"Videos that play fine (no playability error) so the script omits the reason field; YouTube schema changes; extraction on unexpected page states where the reason is not generated.","solutions":["Update the library so the extractor always defaults playabilityReason to a string (e.g. '') when absent.","Log the raw payload to confirm playabilityReason is genuinely missing versus mistyped.","Ensure extraction targets a fully loaded watch page where playerResponse playabilityStatus/reason are populated.","Retry; if persistent across videos, the extractor likely needs updating for a YouTube schema change."],"exampleFix":"// before (page-side extraction)\nreason: playerResponse?.playabilityStatus?.reason\n// after\nreason: playerResponse?.playabilityStatus?.reason ?? ''","handlingStrategy":"validation","validationCode":"const payload = unwrapBrowserResult(raw);\nif (!payload || typeof payload.playabilityReason !== 'string') {\n  throw new Error('Invalid video payload: playabilityReason must be a string');\n}","typeGuard":"function hasPlayabilityReason(p) {\n  return p != null && typeof p === 'object' && typeof p.playabilityReason === 'string';\n}","tryCatchPattern":"try {\n  const info = await video(url);\n} catch (e) {\n  if (e.name === 'CommandExecutionError' && /playabilityReason/.test(e.message)) {\n    console.error('Extractor omitted playabilityReason');\n  }\n  throw e;\n}","preventionTips":["Default playabilityReason to '' in the extraction script when the player response has no reason.","Inspect raw payloads to confirm whether the field is missing vs mistyped.","Keep the extractor aligned with current YouTube playerResponse schema.","Retry once; if it fails across many videos, treat it as a schema change needing a code fix."],"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"}