{"record":{"id":"681f91e61fd26da9","repo":"jackwener/OpenCLI","slug":"failed-to-fetch-youtube-feed","errorCode":null,"errorMessage":"Failed to fetch YouTube feed","messagePattern":"Failed to fetch YouTube feed","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youtube/feed.js","lineNumber":114,"sourceCode":"            const newItems = contData.onResponseReceivedActions?.[0]?.appendContinuationItemsAction?.continuationItems || [];\n            if (!newItems.length) break;\n            for (const item of newItems) {\n              if (videos.length >= limit) break;\n              const v = extractFromItem(item);\n              if (v?.video_id) {\n                videos.push({ rank: videos.length + 1, ...v, url: 'https://www.youtube.com/watch?v=' + v.video_id });\n              }\n            }\n            contItem = newItems[newItems.length - 1];\n          }\n        }\n\n        return videos;\n      })()\n    `);\n        if (!Array.isArray(data)) {\n            const errMsg = data && typeof data === 'object' ? String(data.error || '') : '';\n            throw new CommandExecutionError(errMsg || 'Failed to fetch YouTube feed');\n        }\n        if (data.length === 0) {\n            throw new EmptyResultError('youtube feed');\n        }\n        return data;\n    },\n});\n","sourceCodeStart":96,"sourceCodeEnd":122,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youtube/feed.js#L96-L122","documentation":"CommandExecutionError raised by `youtube feed` when the in-page script returns a non-array and no error string could be extracted from it. The fallback message 'Failed to fetch YouTube feed' is thrown, meaning the feed extraction failed without YouTube surfacing a specific reason.","triggerScenarios":"Running `youtube feed` when the embedded evaluate returns a non-array object lacking a usable `error` string — e.g. null/undefined result, an unexpected object shape after a YouTube DOM change, or the page failing to render the feed in time.","commonSituations":"Logged-out session where the home feed does not render; YouTube A/B test or redesign changing selectors; slow page load causing the script to resolve with a non-array placeholder; browser page crash mid-scrape.","solutions":["Re-run the command — transient page-load issues often resolve on retry.","Check login/cookie state; the personalized feed may require an active session.","If it fails consistently, the feed DOM likely changed — update or patch the extractor script.","Log the raw `data` value by wrapping the call to see what the page actually returned."],"exampleFix":"// before\nawait yt.feed(); // opaque 'Failed to fetch YouTube feed'\n// after\ntry {\n  await yt.feed();\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message === 'Failed to fetch YouTube feed') {\n    console.error('Feed scrape returned non-array data; check session/DOM');\n  } else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isVideoArray(d) {\n  return Array.isArray(d);\n}","tryCatchPattern":"try {\n  const feed = await yt.feed();\n} catch (e) {\n  if (e instanceof CommandExecutionError) {\n    // non-array, non-error payload — likely DOM change or unrendered page\n    await sleep(2000);\n    return yt.feed(); // single retry\n  }\n  throw e;\n}","preventionTips":["Ensure the session has a populated home feed (active account).","Retry once on this generic failure before escalating.","Keep the library updated; this fallback fires when YouTube changes feed markup.","Avoid running in heavily throttled/background tabs."],"tags":["youtube","feed","scraping","command-execution"],"backgroundTag":"page-script-error-forwarded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}