chatboxai/chatbox · warning · ChatboxCliUsageError

Missing --prompt.

Error message

Missing --prompt.

What it means

ChatboxCliUsageError thrown by generateImage when requestedPrompt is empty. requestedPrompt is stringFlag(parsed,'prompt') falling back to the joined positionals; both being empty means the generate command has nothing to render.

Source

Thrown at src/renderer/packages/chatbox-cli/images.ts:160

  const promise = create()
  executionCache.set(key, { signature, promise })
  void promise.catch(() => {
    if (executionCache.get(key)?.promise === promise) executionCache.delete(key)
  })
  if (executionCache.size > 100) {
    const oldest = executionCache.keys().next().value
    if (typeof oldest === 'string') executionCache.delete(oldest)
  }
  return promise
}

async function generateImage(context: ChatboxCliCommandContext): Promise<Record<string, unknown>> {
  if (!context.sessionId) throw new ChatboxCliUsageError('Image generation requires an active chat session.')
  if (!context.toolCallId) throw new ChatboxCliUsageError('Image generation requires a tool call id.')
  const sessionId = context.sessionId
  const toolCallId = context.toolCallId
  const requestedPrompt = stringFlag(context.parsed, 'prompt') ?? context.parsed.positionals.join(' ').trim()
  if (!requestedPrompt) throw new ChatboxCliUsageError('Missing --prompt.')
  if (requestedPrompt.length > 8_000) throw new ChatboxCliUsageError('Prompt must be at most 8000 characters.')

  const requestedProvider = stringFlag(context.parsed, 'provider')
  const requestedModelId = stringFlag(context.parsed, 'model')
  const requestedCount = integerFlag(context.parsed, 'count', { defaultValue: 1, min: 1, max: 4 })
  const requestedAspectRatio = stringFlag(context.parsed, 'aspect-ratio')
  const requestedStyle = stringFlag(context.parsed, 'style')
  if (requestedStyle && requestedStyle !== 'vivid' && requestedStyle !== 'natural') {
    throw new ChatboxCliUsageError('--style must be vivid or natural.')
  }
  const parsedStyle: 'vivid' | 'natural' | undefined =
    requestedStyle === 'vivid' || requestedStyle === 'natural' ? requestedStyle : undefined
  const approvedRequest =
    context.approved && context.approvalDetails?.type === 'image_generation' ? context.approvalDetails : undefined
  if (
    approvedRequest &&
    (approvedRequest.prompt !== requestedPrompt ||
      approvedRequest.count !== requestedCount ||

View on GitHub (pinned to 81571269ad)

Solutions

  1. Always supply a non-empty --prompt (or a positional) with the desired text.
  2. Validate the prompt is non-empty in the caller and prompt the user if blank.
  3. Remember the 8000-character cap when constructing the prompt.

Example fix

// before
await executeChatboxCliCommand({ argv: ['image','generate'] }, ctx)

// after
if (!prompt.trim()) return promptUser('Describe the image to generate')
await executeChatboxCliCommand({ argv: ['image','generate','--prompt', prompt] }, ctx)
Defensive patterns

Strategy: validation

Validate before calling

const prompt = String(rawPrompt ?? '').trim()
if (!prompt) {
  return { error: 'A prompt is required', kind: 'usage' }
}
if (prompt.length > 8_000) {
  return { error: 'Prompt must be at most 8000 characters', kind: 'usage' }
}
await executeChatboxCliCommand({ argv: ['image','generate','--prompt', prompt] }, ctx)

Type guard

function isValidPrompt(input: unknown): input is string {
  return typeof input === 'string' && input.trim().length > 0 && input.length <= 8_000
}

Try / catch

const res = await executeChatboxCliCommand({ argv: ['image','generate','--prompt', p] }, ctx)
if (!res.ok && res.kind === 'usage' && res.error === 'Missing --prompt.') {
  // prompt the user for image text
}

Prevention

When it happens

Trigger: Calling 'image generate' with no --prompt flag and no positional text, or with --prompt '' and no positionals.

Common situations: An LLM tool-call that omitted the prompt, a UI that submitted before the user typed, or a script with an empty prompt variable.

Related errors


AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12). Data as JSON: /api/errors/ed890821bc622ee9. Report an issue: GitHub.