{"record":{"id":"4f24c8584108b442","repo":"jackwener/OpenCLI","slug":"string-data-error-4f24c8","errorCode":null,"errorMessage":"String(data.error)","messagePattern":"String\\(data\\.error\\)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youtube/watch-later.js","lineNumber":68,"sourceCode":"        while (videos.length < limit && contItem?.continuationItemRenderer && apiKey && context) {\n          const token = contItem.continuationItemRenderer?.continuationEndpoint?.continuationCommand?.token;\n          if (!token) break;\n          const contData = await fetchBrowse(apiKey, { context, continuation: token });\n          if (contData.error) break;\n          const newItems = contData.onResponseReceivedActions?.[0]?.appendContinuationItemsAction?.continuationItems || [];\n          if (!newItems.length) break;\n          videos = videos.concat(extractVideos(newItems));\n          contItem = newItems[newItems.length - 1];\n        }\n\n        return { title, stats, videos: videos.slice(0, limit) };\n      })()\n    `);\n        if (!data || typeof data !== 'object') {\n            throw new CommandExecutionError('Failed to fetch Watch Later — make sure you are logged into YouTube');\n        }\n        if (data.error) {\n            throw new CommandExecutionError(String(data.error));\n        }\n        if (!data.videos?.length) {\n            throw new EmptyResultError('youtube watch-later');\n        }\n        const statsStr = (data.stats || []).join(' | ');\n        process.stderr.write(`${data.title}  ${statsStr}\\n`);\n        return data.videos;\n    },\n});\n","sourceCodeStart":50,"sourceCodeEnd":78,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youtube/watch-later.js#L50-L78","documentation":"This error surfaces the dynamic `data.error` value returned by the Watch Later extraction script as a CommandExecutionError. Unlike the login-failure guard, the payload here IS an object, but it carries an explicit `error` field produced by the in-page script (e.g. navigation failure, unexpected page state). The message text is not fixed — it is whatever the extraction script reported, stringified.","triggerScenarios":"Running `youtube watch-later` when the injected evaluation script detects an error condition and returns { error: '...' } — for example the Watch Later page failed to load, a selector found nothing and the script flagged it, or YouTube returned an error interstitial.","commonSituations":"Transient YouTube server errors (500s) during page load; region or consent redirects landing on a different page; the playlist page rendering in an unexpected locale/layout; network interruption mid-navigation.","solutions":["Read the surfaced message — it names the concrete in-page failure the script detected.","Retry after a short delay if the cause looks transient (network, 5xx).","Re-check login/consent state in the CLI browser session.","Update the CLI if the message indicates a page-structure mismatch."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate payload before use; error field presence is the signal\nif (result && typeof result === 'object' && result.error) {\n  throw new Error(`Extraction reported: ${result.error}`);\n}","typeGuard":"const isExtractionError = (d) =>\n  d !== null && typeof d === 'object' && typeof d.error === 'string' && d.error.length > 0;","tryCatchPattern":"try {\n  const videos = await run(['youtube', 'watch-later']);\n} catch (e) {\n  // message is the dynamic in-page error — log it verbatim for diagnosis\n  console.error('watch-later extraction error:', e.message);\n  if (isTransient(e.message)) await sleep(5000), retry();\n  else throw e;\n}","preventionTips":["Log the surfaced message verbatim — it names the concrete in-page failure","Add retry-with-backoff for transient causes (5xx, network)","Keep cookies and CLI version current","Don't blanket-swallow: distinguish this from login and empty-result errors"],"tags":["youtube","scraping","runtime-error","dynamic-message"],"backgroundTag":"in-page-extraction-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}