jackwener/OpenCLI · error · EmptyResultError
qoder read
Error message
qoder read
What it means
Thrown when the qoder read command's DOM-extraction script (QODER_TURNS_JS) fails to return an array, meaning the chat turn scrape did not produce usable data. The library guards with requireArrayResult to fail fast instead of returning garbage. Unlike EmptyResultError, this indicates the extraction script itself broke rather than an empty chat.
Source
Thrown at clis/qoder/read.js:21
import { evaluateQoder, parsePositiveInt, QODER_TURNS_JS, requireArrayResult } from './_utils.js';
cli({
site: 'qoder',
name: 'read',
access: 'read',
description: 'Read messages in the current Qoder Quest. Returns role + text for each visible turn.',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [
{ name: 'limit', type: 'int', required: false, default: 30 },
],
columns: ['Index', 'Role', 'Text'],
func: async (page, kwargs) => {
const limit = parsePositiveInt(kwargs?.limit, 30, '--limit');
const turns = requireArrayResult(await evaluateQoder(page, QODER_TURNS_JS), 'qoder read');
if (!turns.length) {
throw new EmptyResultError('qoder read', 'No chat turns detected. Open a quest first.');
}
return turns.slice(0, limit).map((t, i) => ({
Index: i + 1,
Role: t.role,
Text: (t.text || '').slice(0, 1200),
}));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Open a quest/chat in Qoder first so the turn list exists, then rerun.
- Reload the quest page and retry.
- Inspect the current DOM and update QODER_TURNS_JS selectors to match the new markup.
- Check that you are logged in and the page is fully loaded before running the command.
Defensive patterns
Strategy: type-guard
Validate before calling
const onQuest = await page.evaluate(`!!document.querySelector('[class*="message"], [class*="chat"]')`);
if (!onQuest) throw new Error('Open a quest page before running qoder read'); Type guard
function isTurnArray(v) { return Array.isArray(v) && v.every(t => t && typeof t.text === 'string'); } Try / catch
try {
const turns = await read(page);
} catch (e) {
if (/qoder read/.test(String(e.message))) {
await page.reload();
return read(page);
}
throw e;
} Prevention
- Always open/verify a quest before calling read.
- Reload the page after Qoder updates to avoid stale DOM.
- Treat EmptyResultError (empty chat) and this array failure differently when handling.
- Re-verify QODER_TURNS_JS selectors whenever the Qoder frontend updates.
When it happens
Trigger: Qoder's chat DOM changed so QODER_TURNS_JS returns null/undefined or a non-array; evaluateQoder threw or returned an error object; the page is not on a quest/chat view (no message list mounted).
Common situations: Qoder frontend update renaming message-list containers; running qoder read before opening any quest so the turn container doesn't exist; a stale logged-out page where the chat never renders.
Related errors
- Ctrip round-trip flight DOM extraction returned malformed ro
- Ctrip round-trip flight cards rendered but parser did not fi
- Ctrip round-trip flight rows were missing required airline/f
- Ctrip package DOM extraction returned malformed rows
- Ctrip package cards rendered but parser did not find require
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9f4562e7c231993a.
Report an issue: GitHub.