{"record":{"id":"f51beaaab8ab767f","repo":"jackwener/OpenCLI","slug":"text-is-required","errorCode":null,"errorMessage":"text is required","messagePattern":"text is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"warning","filePath":"clis/qoder/quest.js","lineNumber":63,"sourceCode":"    },\n});\n\n// -------- send --------\ncli({\n    site: 'qoder',\n    name: 'send',\n    access: 'write',\n    description: 'Type text into the Qoder composer and click \"Send message\" (fire-and-forget).',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'text', positional: true, required: true, help: 'Text to send' },\n    ],\n    columns: ['Status', 'Length'],\n    func: async (page, kwargs) => {\n        const text = String(kwargs?.text || '').trim();\n        if (!text) throw new ArgumentError('text is required');\n\n        const beforeCount = await evaluateQoder(page, QODER_MESSAGE_COUNT_JS);\n        const typeRes = await evaluateQoder(page, buildQoderInjectTextScript(text));\n        if (!typeRes?.ok) throw new CommandExecutionError(typeRes?.reason || 'composer type failed', '');\n        await page.wait(0.3);\n\n        // Click Send message\n        const sendRes = await evaluateQoder(page, clickFirstScript([\n            'button[aria-label=\"Send message\"]',\n            'button[title=\"Send message\"]',\n        ]));\n        if (!sendRes?.ok) {\n            // Fallback: try clickByText.\n            const textRes = await evaluateQoder(page, clickByTextScript(['Send message', 'Send', '发送']));\n            if (!textRes?.ok) throw new CommandExecutionError('Send button not found', '');\n        }\n        const afterCount = await waitForMessageCountGrowth(page, beforeCount);\n        if (Number(afterCount) <= Number(beforeCount)) {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qoder/quest.js#L45-L81","documentation":"An ArgumentError thrown by the qoder send command's argument validation. Even though the positional 'text' arg is declared required, the command re-validates: it coerces kwargs.text to a string, trims it, and throws if the result is empty. This guards against whitespace-only or empty input reaching the composer automation.","triggerScenarios":"Running `qoder send` with: no positional argument at all; an argument that is only whitespace (e.g. `qoder send \"   \"`); an empty shell-expanded variable (`qoder send \"$EMPTY\"`); or a caller passing text under a different kwarg name so kwargs.text is undefined.","commonSituations":"Shell scripts quoting text incorrectly so the positional is dropped; variables that expand to empty because a previous command failed; CI pipelines passing env vars that are unset; users forgetting the positional because other commands take only flags.","solutions":["Pass non-empty prompt text as the positional argument: `qoder send \"Fix the failing test in auth.js\"`.","Trim-check the input in your shell script before calling: `[ -n \"${TEXT// }\" ] || exit 1`.","If using variables, quote them (\"$TEXT\") and verify they are set (`: \"${TEXT:?TEXT is unset}\"`) before invoking send.","Use the `ask` command instead if you also need the reply — it has the same text requirement but waits for a response."],"exampleFix":"// before\nconst text = String(kwargs?.text || '').trim();\nif (!text) throw new ArgumentError('text is required');\n// after (caller side, shell)\n// qoder send \"$PROMPT\"          # quoted, non-empty PROMPT verified with :? above","handlingStrategy":"validation","validationCode":"# Shell: fail fast before invoking qoder send\n: \"${PROMPT:?PROMPT is unset or empty}\"\nPROMPT_TRIMMED=$(echo \"$PROMPT\" | tr -d '[:space:]')\n[ -n \"$PROMPT_TRIMMED\" ] || { echo 'text is required'; exit 1; }\nqoder send \"$PROMPT\"","typeGuard":"function isNonEmptyText(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await runCli('qoder send', [text]);\n} catch (e) {\n  if (String(e.message) === 'text is required') {\n    throw new Error('Caller bug: prompt text was empty/whitespace — check variable expansion');\n  }\n  throw e;\n}","preventionTips":["Quote positional args in shell (\"$TEXT\") so empty expansion doesn't drop the arg.","Trim and assert prompt text before every send call in scripts.","Use :? parameter expansion to fail fast on unset variables.","Remember both send and ask require a non-empty positional text."],"tags":["argument-validation","cli","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}