{"record":{"id":"c2e55f04dea102f2","repo":"jackwener/OpenCLI","slug":"string-data-error-c2e55f","errorCode":null,"errorMessage":"String(data.error)","messagePattern":"String\\(data\\.error\\)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youtube/channel.js","lineNumber":205,"sourceCode":"          }\n        }\n\n        return {\n          name: metadata.title || '',\n          channelId: metadata.externalId || browseId,\n          handle: metadata.vanityChannelUrl?.split('/').pop() || '',\n          description: (metadata.description || '').substring(0, 500),\n          subscribers: subscriberCount,\n          url: metadata.channelUrl || 'https://www.youtube.com/channel/' + browseId,\n          keywords: metadata.keywords || '',\n          recentVideos,\n        };\n      })()\n    `);\n        if (!data || typeof data !== 'object')\n            throw new CommandExecutionError('Failed to fetch channel data');\n        if (data.error)\n            throw new CommandExecutionError(String(data.error));\n        const result = data;\n        const videos = result.recentVideos;\n        delete result.recentVideos;\n        // Channel info as field/value pairs + recent videos as table\n        const rows = Object.entries(result).map(([field, value]) => ({\n            field,\n            value: String(value),\n        }));\n        if (videos && videos.length > 0) {\n            rows.push({ field: '---', value: '--- Recent Videos ---' });\n            for (const v of videos) {\n                rows.push({ field: v.title, value: `${v.duration} | ${v.views} | ${v.url}` });\n            }\n        }\n        return rows;\n    },\n});\n","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youtube/channel.js#L187-L223","documentation":"CommandExecutionError raised by `youtube channel` when the in-page evaluate script returns an object with an `error` property. The library forwards YouTube's own error string (String(data.error)) so the developer sees the underlying page-side failure. It means the fetch script ran but reported a failure instead of channel data.","triggerScenarios":"Running the `youtube channel` command when the embedded page.evaluate script returns {error: ...} — e.g. YouTube returned an error response, the channel handle/ID does not resolve, or the page DOM/API shape changed and the script caught an exception and reported it via data.error.","commonSituations":"Scraping a non-existent or removed channel handle; running without a page prepared for YouTube (region/consent wall); YouTube internal API changes after a site update; transient network failures inside the browser page.","solutions":["Read the forwarded message — it is YouTube's own error string; fix the underlying cause it names.","Verify the channel handle/URL passed to the command exists and is current.","Re-run after checking login/cookie state, since private/restricted data can surface as a page error.","Retry later or update the library if YouTube changed its page structure (data.error persists for all channels)."],"exampleFix":"// before\nconst { data } = await run(); // throws with raw YouTube error string\n// after\ntry {\n  const { data } = await run();\n} catch (e) {\n  if (e instanceof CommandExecutionError) {\n    console.error('YouTube channel fetch failed:', e.message); // inspect forwarded page error\n  } else throw e;\n}","handlingStrategy":"try-catch","validationCode":"const handle = 'yours';\nif (!handle || typeof handle !== 'string') throw new Error('channel handle required');","typeGuard":"function hasError(d) {\n  return typeof d === 'object' && d !== null && 'error' in d && Boolean(d.error);\n}","tryCatchPattern":"try {\n  const channel = await yt.channel(handle);\n} catch (e) {\n  if (e instanceof CommandExecutionError) {\n    console.error(`channel fetch failed: ${e.message}`); // message is YouTube's own error\n  } else throw e;\n}","preventionTips":["Validate the channel handle/URL before invoking.","Check YouTube login/cookie state for restricted channels.","Retry on transient failures; treat persistent errors for all channels as a DOM change needing a library update.","Log the forwarded message — it names the page-side cause."],"tags":["youtube","scraping","page-evaluate","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"}