{"record":{"id":"d4f94d3812246f49","repo":"jackwener/OpenCLI","slug":"prompt-is-required","errorCode":null,"errorMessage":"prompt is required","messagePattern":"prompt is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/grok/send.js","lineNumber":30,"sourceCode":"\ncli({\n    site: 'grok',\n    name: 'send',\n    access: 'write',\n    description: 'Fire-and-forget: send a prompt to Grok without waiting for the reply',\n    domain: GROK_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'prompt', required: true, positional: true, help: 'Prompt to send to Grok' },\n        { name: 'new', type: 'boolean', default: false, help: 'Start a new chat before sending' },\n    ],\n    columns: ['Status', 'Prompt'],\n    func: async (page, kwargs) => {\n        const prompt = String(kwargs.prompt || '').trim();\n        if (!prompt) throw new ArgumentError('prompt', 'is required');\n        const startFresh = normalizeBooleanFlag(kwargs.new, false);\n\n        await ensureOnGrok(page);\n        if (startFresh) {\n            await startNewChat(page);\n        }\n\n        const send = await sendMessage(page, prompt);\n        if (!send?.ok) {\n            // If the composer is missing, the most likely cause is that the\n            // signed-in session expired (Grok then renders a sign-in CTA in\n            // place of the composer). Surface that as AuthRequiredError so\n            // agents can prompt for re-auth instead of treating it as a\n            // generic execution failure.\n            if (!(await isLoggedIn(page))) throw authRequired();\n            throw new CommandExecutionError(send?.reason || 'Failed to send Grok prompt');\n        }\n        return [{ Status: 'sent', Prompt: prompt }];","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/send.js#L12-L48","documentation":"The send command requires a positional prompt; the value is stringified and trimmed, and if the result is empty an ArgumentError('prompt', 'is required') is thrown. Empty prompts cannot be submitted to Grok, so the command fails fast before touching the browser.","triggerScenarios":"Running the send command with no positional argument, --prompt '', --prompt '   ' (whitespace only), or kwargs.prompt being undefined/null.","commonSituations":"Shell variable holding the prompt was empty/unset, quoting mistake dropping the argument, or a script piping an empty string into the CLI.","solutions":["Pass a non-empty prompt as the positional argument.","Check that the shell variable feeding the prompt is set and non-blank.","Quote the prompt to preserve spaces and avoid shell word-splitting."],"exampleFix":"// before\ncli send \"$PROMPT\"   # PROMPT is empty\n// after\ncli send \"Explain event loops\"   # or: : \"${PROMPT:?PROMPT must be set}\"","handlingStrategy":"validation","validationCode":"const prompt = (process.argv[2] ?? '').trim();\nif (!prompt) {\n  console.error('usage: cli send <non-empty prompt>');\n  process.exit(2);\n}","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await cli.send({ prompt });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message === 'prompt is required') {\n    console.error('Provide a non-empty prompt as the positional argument.');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Trim and check the prompt before invoking the command.","Use ${PROMPT:?msg} to fail fast on unset shell variables.","Always quote prompts in the shell to preserve whitespace.","In scripts, assert prompt length > 0 before calling the CLI."],"tags":["validation","argument-error","cli-options"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}