jackwener/OpenCLI · warning · ArgumentError

text is required

Error message

text is required

What it means

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.

Source

Thrown at clis/qoder/quest.js:63

    },
});

// -------- send --------
cli({
    site: 'qoder',
    name: 'send',
    access: 'write',
    description: 'Type text into the Qoder composer and click "Send message" (fire-and-forget).',
    domain: 'localhost',
    strategy: Strategy.UI,
    browser: true,
    args: [
        { name: 'text', positional: true, required: true, help: 'Text to send' },
    ],
    columns: ['Status', 'Length'],
    func: async (page, kwargs) => {
        const text = String(kwargs?.text || '').trim();
        if (!text) throw new ArgumentError('text is required');

        const beforeCount = await evaluateQoder(page, QODER_MESSAGE_COUNT_JS);
        const typeRes = await evaluateQoder(page, buildQoderInjectTextScript(text));
        if (!typeRes?.ok) throw new CommandExecutionError(typeRes?.reason || 'composer type failed', '');
        await page.wait(0.3);

        // Click Send message
        const sendRes = await evaluateQoder(page, clickFirstScript([
            'button[aria-label="Send message"]',
            'button[title="Send message"]',
        ]));
        if (!sendRes?.ok) {
            // Fallback: try clickByText.
            const textRes = await evaluateQoder(page, clickByTextScript(['Send message', 'Send', '发送']));
            if (!textRes?.ok) throw new CommandExecutionError('Send button not found', '');
        }
        const afterCount = await waitForMessageCountGrowth(page, beforeCount);
        if (Number(afterCount) <= Number(beforeCount)) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass non-empty prompt text as the positional argument: `qoder send "Fix the failing test in auth.js"`.
  2. Trim-check the input in your shell script before calling: `[ -n "${TEXT// }" ] || exit 1`.
  3. If using variables, quote them ("$TEXT") and verify they are set (`: "${TEXT:?TEXT is unset}"`) before invoking send.
  4. Use the `ask` command instead if you also need the reply — it has the same text requirement but waits for a response.

Example fix

// before
const text = String(kwargs?.text || '').trim();
if (!text) throw new ArgumentError('text is required');
// after (caller side, shell)
// qoder send "$PROMPT"          # quoted, non-empty PROMPT verified with :? above
Defensive patterns

Strategy: validation

Validate before calling

# Shell: fail fast before invoking qoder send
: "${PROMPT:?PROMPT is unset or empty}"
PROMPT_TRIMMED=$(echo "$PROMPT" | tr -d '[:space:]')
[ -n "$PROMPT_TRIMMED" ] || { echo 'text is required'; exit 1; }
qoder send "$PROMPT"

Type guard

function isNonEmptyText(v) {
  return typeof v === 'string' && v.trim().length > 0;
}

Try / catch

try {
  await runCli('qoder send', [text]);
} catch (e) {
  if (String(e.message) === 'text is required') {
    throw new Error('Caller bug: prompt text was empty/whitespace — check variable expansion');
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/f51beaaab8ab767f. Report an issue: GitHub.