{"record":{"id":"1bb58885895e8e19","repo":"jackwener/OpenCLI","slug":"reply-failed-result-detail","errorCode":null,"errorMessage":"Reply failed: ${result.detail}","messagePattern":"Reply failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/reddit/reply.js","lineNumber":175,"sourceCode":"      } catch (e) {\n        return { kind: 'exception', detail: String(e && e.message || e) };\n      }\n    })()`);\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 === 'reddit-error') {\n            throw new CommandExecutionError(`Reddit rejected reply: ${result.detail}`);\n        }\n        if (result?.kind === 'postcondition') {\n            throw new CommandExecutionError(result.detail);\n        }\n        if (result?.kind === 'exception') {\n            throw new CommandExecutionError(`Reply failed: ${result.detail}`);\n        }\n        if (result?.kind !== 'ok') {\n            throw new CommandExecutionError(`Unexpected result from reddit reply: ${JSON.stringify(result)}`);\n        }\n        return [{ status: 'success', message: result.detail }];\n    },\n});\n","sourceCodeStart":157,"sourceCodeEnd":183,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reddit/reply.js#L157-L183","documentation":"Thrown by the reddit `reply` command when the in-page script throws a JavaScript exception inside page.evaluate (result.kind === 'exception'). The browser-side try/catch converts the thrown error to a string and this error surfaces it as `Reply failed: <detail>`. It means the automation script itself crashed (DOM change, null access, network failure inside the page), not that Reddit rejected the content.","triggerScenarios":"Calling the reddit reply command when the page.evaluate async function throws: e.g. a fetch inside the page fails, a DOM element the script expects (comment box, submit button) is missing, or an unhandled null/undefined access in the injected script.","commonSituations":"Reddit UI/markup changes breaking selectors the injected script relies on; Reddit serving an interstitial (blocked, captcha) page instead of the post; intermittent network failures inside the browser session.","solutions":["Read the `detail` suffix to identify the underlying in-page exception","Check that the browser session is on a normal reddit.com page, not an error or captcha interstitial","Update the CLI/automation script if Reddit changed its DOM or API endpoints","Retry once after a delay in case of a transient in-page network failure","Catch CommandExecutionError and fall back to manual posting"],"exampleFix":"// before\nawait cli.run('reddit reply', { 'post-id': id, text });\n// after\ntry {\n  await cli.run('reddit reply', { 'post-id': id, text });\n} catch (e) {\n  if (e.message.startsWith('Reply failed:')) await new Promise(r => setTimeout(r, 2000)).then(() => retry());\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Confirm a healthy session page before invoking:\nif (!page || !page.url().includes('reddit.com')) throw new Error('Open reddit.com in the session first');","typeGuard":"function isExceptionResult(r) {\n  return r != null && typeof r === 'object' && r.kind === 'exception' && typeof r.detail === 'string';\n}","tryCatchPattern":"try {\n  await cli.run('reddit reply', { 'post-id': postId, text });\n} catch (e) {\n  if (e.message.startsWith('Reply failed:')) {\n    console.error('In-page exception:', e.message);\n    await sleep(2000); // retry once for transient in-page failures\n  } else throw e;\n}","preventionTips":["Keep the CLI updated — Reddit DOM/API changes break the injected script","Watch for captcha/blocked interstitials in the browser session","Retry once with backoff for transient in-page network errors"],"tags":["reddit","browser-automation","page-evaluate"],"backgroundTag":"browser-script-exception","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}