chatboxai/chatbox · warning · ChatboxCliUsageError

Missing search query.

Error message

Missing search query.

What it means

ChatboxCliUsageError thrown by the 'chats search' command when parsed.positionals joined and trimmed yields an empty string. It signals a malformed virtual-CLI invocation rather than a runtime failure; executeChatboxCliCommand catches it and returns { ok:false, kind:'usage' }.

Source

Thrown at src/renderer/packages/chatbox-cli/chats.ts:76

          name: item.name,
          type: item.type ?? 'chat',
          starred: Boolean(item.starred),
          archivedAt: item.archivedAt,
          createdAt: item.createdAt,
        })),
        nextCursor: page.nextCursor,
        total: page.total,
        archived,
      }
    },
  },
  {
    path: ['chats', 'search'],
    description: 'Search message text across conversation history without approval.',
    usage: 'chatbox chats search <query> [--limit 10]',
    async execute({ parsed }) {
      const query = parsed.positionals.join(' ').trim()
      if (!query) throw new ChatboxCliUsageError('Missing search query.')
      const limit = integerFlag(parsed, 'limit', { defaultValue: 10, min: 1, max: 20 })
      const hits: Record<string, unknown>[] = []

      await searchSessions(query, undefined, (sessions) => {
        for (const session of sessions) {
          for (const message of session.messages) {
            if (hits.length >= limit) return
            if (!isReadableConversationMessage(message)) continue
            hits.push({
              sessionId: session.id,
              sessionName: session.name,
              ...compactMessage(message),
            })
          }
        }
      })
      return { scope: 'global', query, hits, limitReached: hits.length >= limit }
    },

View on GitHub (pinned to 81571269ad)

Solutions

  1. Always pass a non-empty positional query, e.g. argv ['chats','search','hello'].
  2. Trim and validate the query in the caller before dispatching and prompt the user if blank.
  3. Prefer structured argv over a tokenized command string to avoid quoting edge cases.

Example fix

// before
await executeChatboxCliCommand({ argv: ['chats', 'search'] }, ctx)

// after
const q = userInput.trim()
if (!q) return promptUser('Enter a search query')
await executeChatboxCliCommand({ argv: ['chats', 'search', q] }, ctx)
Defensive patterns

Strategy: validation

Validate before calling

const query = String(rawQuery ?? '').trim()
if (!query) {
  return { error: 'A search query is required', kind: 'usage' }
}
await executeChatboxCliCommand({ argv: ['chats', 'search', query] }, ctx)

Type guard

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

Try / catch

const res = await executeChatboxCliCommand({ argv: ['chats','search', query] }, ctx)
if (!res.ok && res.kind === 'usage') {
  // query missing/blank: prompt the user for a search term
}

Prevention

When it happens

Trigger: Calling chats search with no positional arguments, or with only whitespace arguments (e.g. ['chats','search',' ']).

Common situations: An LLM tool-call that omitted the query, a UI that built the argv without user text, or a script invoking the CLI with an empty search term.

Related errors


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