jackwener/OpenCLI · error · CommandExecutionError
unexpected evaluate envelope: ${JSON.stringify(r)}
Error message
unexpected evaluate envelope: ${JSON.stringify(r)} What it means
dispatchEvaluateResult's default branch throws CommandExecutionError with `unexpected evaluate envelope: <JSON>`. A null or unrecognized envelope indicates contract drift between the injected browser snippet and the CLI dispatcher — the snippet returned something outside the documented {kind: ...} protocol (following the 'fail loud' reddit precedent).
Source
Thrown at clis/slock/errors.js:28
// { kind: 'no-thread', parent } // handled by caller, never reaches dispatcher
export function dispatchEvaluateResult(r) {
switch (r && r.kind) {
case 'ok':
return r.rows;
case 'auth':
throw new AuthRequiredError(SLOCK_DOMAIN, r.detail);
case 'http':
throw new CommandExecutionError(`HTTP ${r.status} from ${r.where}`);
case 'no-server':
throw new ConfigError(r.detail, 'Run `opencli slock server-use <slug>` to set the active server.');
case 'unresolvable':
throw new ArgumentError(r.detail);
case 'no-thread':
// caller decides what to do (returns a 0-row hint); should never reach here
throw new CommandExecutionError(`no-thread should be handled by caller, not dispatcher: ${r.parent}`);
default:
// unknown / null envelope = contract drift; fail loud (reddit precedent)
throw new CommandExecutionError(`unexpected evaluate envelope: ${JSON.stringify(r)}`);
}
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Rerun the command — transient navigation/CSP interruptions often resolve on retry
- Upgrade the CLI so snippet and dispatcher versions match
- Inspect the JSON in the message: if it's null, check the browser session/URL loads correctly; if it has an unexpected kind, report the contract drift
Defensive patterns
Strategy: retry
Validate before calling
const envelope = result && typeof result === 'object' && typeof result.kind === 'string' ? result : null;
if (!envelope) throw new Error('evaluate returned no envelope — page may have navigated or script was blocked'); Type guard
const isEnvelope = (r) => r != null && typeof r === 'object' && ['ok','auth','http','no-server','unresolvable','no-thread'].includes(r.kind);
Try / catch
try { return dispatchEvaluateResult(result); } catch (e) { if (/unexpected evaluate envelope/.test(e.message)) { await page.reload(); return retryWithBackoff(task, 2); } throw e; } Prevention
- Avoid navigating or reloading the page while commands run
- Keep snippet and dispatcher versions in sync (upgrade the whole CLI)
- Check for browser extensions/CSP that strip injected scripts
When it happens
Trigger: page.evaluate returned null/undefined (snippet crashed or was blocked, e.g. CSP, navigation interrupted), or a modified/older snippet returned a shape without a recognized kind field.
Common situations: Browser page navigated mid-evaluate so the result is null; antivirus/extension stripping the injected script; half-updated CLI where snippet and dispatcher versions disagree.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- no-thread should be handled by caller, not dispatcher: ${r.p
- expected files array, got ${typeof files} (contract drift?)
- expected array of rows from server, got ${typeof rows} (cont
- expected array of DM channels, got ${typeof rows} (contract
- expected inbox items array, got ${typeof items} (contract dr
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c78dcf842d977ed0.
Report an issue: GitHub.