{"record":{"id":"a886ad0a0e7ddc5a","repo":"jackwener/OpenCLI","slug":"commandname-prompt-cannot-be-empty-a886ad","errorCode":null,"errorMessage":"${commandName} prompt cannot be empty","messagePattern":"(.+?) prompt cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/claude/utils.js","lineNumber":72,"sourceCode":"    const state = await getPageState(page);\n    if (!state.isLoggedIn) {\n        throw new AuthRequiredError(CLAUDE_DOMAIN, message);\n    }\n    return state;\n}\n\nexport async function ensureClaudeComposer(page, message = 'Claude composer is not available on the current page.') {\n    const state = await ensureClaudeLogin(page, message);\n    if (!state.hasComposer) {\n        throw new CommandExecutionError(message);\n    }\n    return state;\n}\n\nexport function requireNonEmptyPrompt(prompt, commandName) {\n    const text = String(prompt ?? '').trim();\n    if (!text) {\n        throw new ArgumentError(\n            `${commandName} prompt cannot be empty`,\n            `Example: opencli ${commandName} \"hello\"`,\n        );\n    }\n    return text;\n}\n\nexport function requirePositiveInt(value, flagLabel, hint) {\n    if (!Number.isInteger(value) || value < 1) {\n        throw new ArgumentError(`${flagLabel} must be a positive integer`, hint);\n    }\n    return value;\n}\n\nexport function requireConversationId(value) {\n    const id = String(value ?? '').trim();\n    if (!id) {\n        throw new ArgumentError(","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/claude/utils.js#L54-L90","documentation":"requireNonEmptyPrompt validates that the prompt argument for a Claude command is a non-empty, non-whitespace string. opencli throws this ArgumentError early rather than launching a browser session to send an empty message.","triggerScenarios":"Calling a claude command (ask/new/send) with an empty string, whitespace-only string, or null/undefined prompt, e.g. `opencli claude ask \"\"` or passing a shell variable that expanded to nothing.","commonSituations":"Shell variable not set (`opencli claude ask \"$PROMPT\"` with PROMPT empty), quoting mistakes in scripts, piping empty stdin, CI jobs with missing inputs.","solutions":["Pass a non-empty quoted prompt as the command argument","Check the variable/pipe feeding the prompt is populated before invoking","In scripts, guard with a check like `[ -n \"$PROMPT\" ] || exit 1`"],"exampleFix":"// before\nconst prompt = process.env.PROMPT; // may be ''\nawait requireNonEmptyPrompt(prompt, 'ask');\n// after\nconst prompt = process.env.PROMPT?.trim();\nif (!prompt) throw new Error('PROMPT env var is required');\nawait requireNonEmptyPrompt(prompt, 'ask');","handlingStrategy":"validation","validationCode":"const text = String(prompt ?? '').trim();\nif (!text) {\n  throw new Error('Prompt must be a non-empty string');\n}\nawait requireNonEmptyPrompt(text, 'ask');","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await requireNonEmptyPrompt(prompt, 'ask');\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('prompt cannot be empty')) {\n    console.error('Usage: opencli ask \"hello\"');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Always quote prompt arguments in shell scripts","Validate env vars feeding prompts with [ -n \"$PROMPT\" ]","Trim user input before passing it on","Fail fast in CI when required prompt inputs are empty"],"tags":["validation","argument-error","cli"],"backgroundTag":"empty-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}