{"record":{"id":"99ad87dbedc32193","repo":"jackwener/OpenCLI","slug":"reddit-comments-fetch-returned-no-result-envelope","errorCode":null,"errorMessage":"Reddit /comments fetch returned no result envelope.","messagePattern":"Reddit /comments fetch returned no result envelope\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/reddit/read.js","lineNumber":563,"sourceCode":"            url_overridden_by_dest: '',\n            preview_image_url: '',\n            gallery_urls: [],\n          });\n        }\n\n        // If we produced nothing beyond the POST row but the comment listing\n        // wasn't empty, that's parser drift (e.g. Reddit changed t1/more\n        // schema). Surface as CommandExecutionError on the Node side.\n        if (rows.length <= 1 && preWalkSize > 0 && t1TopLevel.length > 0) {\n          return { kind: 'parser-drift', detail: 'Reddit comment listing for post ' + postId + ' had ' + t1TopLevel.length + ' t1 entries but walker produced no rows.' };\n        }\n\n        return { kind: 'ok', rows: rows, expandMeta: expandMeta };\n      })()\n    `);\n\n        if (!result || typeof result !== 'object') {\n            throw new CommandExecutionError('Reddit /comments fetch returned no result envelope.');\n        }\n        if (result.kind === 'inaccessible') {\n            throw new EmptyResultError(result.detail);\n        }\n        if (result.kind === 'auth') {\n            throw new AuthRequiredError('reddit.com', 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 === 'parser-drift') {\n            throw new CommandExecutionError(result.detail);\n        }\n        if (result.kind === 'expand-failed') {\n            throw new CommandExecutionError(result.detail);","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reddit/read.js#L545-L581","documentation":"After running the in-page browser script that fetches Reddit's /comments endpoint, the host command checks the returned envelope. If the script returned null/undefined or a non-object (e.g. the page navigated away, the script threw at top level, or serialization failed), a CommandExecutionError is thrown because no result envelope exists to interpret.","triggerScenarios":"The injected page script crashes before producing its result object, the browser page navigates/closes mid-evaluation, or the evaluation returns undefined due to a syntax/runtime failure in the IIFE.","commonSituations":"Reddit serving an unexpected interstitial (login wall, block page) that breaks the script; flaky browser automation; a library/version update changing the script's return shape.","solutions":["Re-run the command; transient page/automation failures often resolve on retry.","Check that the browser session is alive and cookies (Strategy.COOKIE auth) are still valid.","Inspect for Reddit blocking/interstitial pages and retry from a normal browser to verify access."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (!browserAlive || page.isClosed?.()) await restartBrowserSession();","typeGuard":"null","tryCatchPattern":"try {\n  const rows = await redditRead(postId);\n} catch (e) {\n  if (e instanceof CommandExecutionError && /no result envelope/.test(e.message)) {\n    await sleep(2000);\n    return redditRead(postId); // retry once\n  }\n  throw e;\n}","preventionTips":["Keep the browser session healthy (no navigation/close races during evaluation).","Retry transient in-page failures once with a short backoff before giving up.","Keep the library updated so the injected script matches the host handler."],"tags":["browser-automation","reddit","unexpected-null"],"backgroundTag":"empty-script-result-envelope","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}