{"record":{"id":"98e5c247ee359d88","repo":"jackwener/OpenCLI","slug":"unexpected-result-from-reddit-subreddit-info-js","errorCode":null,"errorMessage":"Unexpected result from reddit subreddit-info: ${JSON.stringify(result)}","messagePattern":"Unexpected result from reddit subreddit-info: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/reddit/subreddit-info.js","lineNumber":89,"sourceCode":"      } catch (e) {\n        return { kind: 'exception', detail: String(e && e.message || e) };\n      }\n    })()`);\n\n        if (result?.kind === 'missing') {\n            throw new EmptyResultError(result.detail);\n        }\n        if (result?.kind === 'http') {\n            throw new CommandExecutionError(`HTTP ${result.httpStatus} from ${result.where}`);\n        }\n        if (result?.kind === 'malformed') {\n            throw new CommandExecutionError(result.detail);\n        }\n        if (result?.kind === 'exception') {\n            throw new CommandExecutionError(`subreddit-info failed: ${result.detail}`);\n        }\n        if (result?.kind !== 'ok') {\n            throw new CommandExecutionError(`Unexpected result from reddit subreddit-info: ${JSON.stringify(result)}`);\n        }\n\n        const s = result.info;\n        const created = s.created_utc\n            ? new Date(s.created_utc * 1000).toISOString().split('T')[0]\n            : null;\n        const subscribers = typeof s.subscribers === 'number' ? s.subscribers : null;\n        const activeNow = typeof s.active_user_count === 'number'\n            ? s.active_user_count\n            : (typeof s.accounts_active === 'number' ? s.accounts_active : null);\n        const description = typeof s.public_description === 'string'\n            ? s.public_description.trim()\n            : '';\n\n        return [\n            { field: 'Name', value: s.display_name_prefixed || ('r/' + s.display_name) },\n            { field: 'Title', value: typeof s.title === 'string' ? s.title : null },\n            { field: 'Subscribers', value: subscribers != null ? String(subscribers) : null },","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reddit/subreddit-info.js#L71-L107","documentation":"CommandExecutionError thrown as a defensive fallthrough when the browser-evaluated result has an unrecognized 'kind' (or result itself is null/undefined). All known kinds (missing/http/malformed/exception/ok) are handled above, so this indicates an unexpected runtime contract violation between the page.evaluate payload and the Node handler.","triggerScenarios":"result is undefined or null (evaluate returned nothing, page navigated during evaluation), or a future/unknown kind value appears after a library version mismatch between the browser snippet and the Node-side handler.","commonSituations":"Page context destroyed mid-evaluate so evaluate resolves undefined; running a mixed/patched version of the library where the browser snippet returns new kinds the Node handler does not know; serialization dropping the object.","solutions":["Retry the command — a transient page navigation can make evaluate return undefined","Ensure a single consistent version of the library is installed (no mixed patched copies) and reinstall if in doubt","Report the printed JSON.stringify(result) payload in a bug report — it shows exactly what unexpected shape came back","Avoid interfering with the browser window while the command runs so the page is not navigated away mid-evaluation"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// run a smoke invocation first and assert a known kind is returned\nconst probe = await cli.redditSubredditInfo('python');\nif (!probe) throw new Error('evaluate returned undefined; environment broken');","typeGuard":"function isUnexpectedResultErr(e){ return e instanceof Error && e.message.startsWith('Unexpected result from reddit subreddit-info:'); }","tryCatchPattern":"try { await cli.redditSubredditInfo(name); }\ncatch (e) {\n  if (e.message.startsWith('Unexpected result from reddit subreddit-info:')) {\n    reportBug(e.message); // message embeds JSON.stringify(result)\n    return null;\n  }\n  throw e;\n}","preventionTips":["Install a single consistent library version (no mixed patched copies)","Don't navigate/crash the page during evaluation, which can make evaluate return undefined","Include the embedded JSON payload when filing bug reports","Retry once before escalating — some cases are transient page-context losses"],"tags":["reddit","internal-error","unexpected-result","browser"],"backgroundTag":"unexpected-result-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}