{"record":{"id":"57a5505e4da5c7ae","repo":"chatboxai/chatbox","slug":"missing-search-query","errorCode":null,"errorMessage":"Missing search query.","messagePattern":"Missing search query\\.","errorType":"validation","errorClass":"ChatboxCliUsageError","httpStatus":null,"severity":"warning","filePath":"src/renderer/packages/chatbox-cli/chats.ts","lineNumber":76,"sourceCode":"          name: item.name,\n          type: item.type ?? 'chat',\n          starred: Boolean(item.starred),\n          archivedAt: item.archivedAt,\n          createdAt: item.createdAt,\n        })),\n        nextCursor: page.nextCursor,\n        total: page.total,\n        archived,\n      }\n    },\n  },\n  {\n    path: ['chats', 'search'],\n    description: 'Search message text across conversation history without approval.',\n    usage: 'chatbox chats search <query> [--limit 10]',\n    async execute({ parsed }) {\n      const query = parsed.positionals.join(' ').trim()\n      if (!query) throw new ChatboxCliUsageError('Missing search query.')\n      const limit = integerFlag(parsed, 'limit', { defaultValue: 10, min: 1, max: 20 })\n      const hits: Record<string, unknown>[] = []\n\n      await searchSessions(query, undefined, (sessions) => {\n        for (const session of sessions) {\n          for (const message of session.messages) {\n            if (hits.length >= limit) return\n            if (!isReadableConversationMessage(message)) continue\n            hits.push({\n              sessionId: session.id,\n              sessionName: session.name,\n              ...compactMessage(message),\n            })\n          }\n        }\n      })\n      return { scope: 'global', query, hits, limitReached: hits.length >= limit }\n    },","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/chatbox-cli/chats.ts#L58-L94","documentation":"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' }.","triggerScenarios":"Calling chats search with no positional arguments, or with only whitespace arguments (e.g. ['chats','search','   ']).","commonSituations":"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.","solutions":["Always pass a non-empty positional query, e.g. argv ['chats','search','hello'].","Trim and validate the query in the caller before dispatching and prompt the user if blank.","Prefer structured argv over a tokenized command string to avoid quoting edge cases."],"exampleFix":"// before\nawait executeChatboxCliCommand({ argv: ['chats', 'search'] }, ctx)\n\n// after\nconst q = userInput.trim()\nif (!q) return promptUser('Enter a search query')\nawait executeChatboxCliCommand({ argv: ['chats', 'search', q] }, ctx)","handlingStrategy":"validation","validationCode":"const query = String(rawQuery ?? '').trim()\nif (!query) {\n  return { error: 'A search query is required', kind: 'usage' }\n}\nawait executeChatboxCliCommand({ argv: ['chats', 'search', query] }, ctx)","typeGuard":"function isNonEmptyQuery(input: unknown): input is string {\n  return typeof input === 'string' && input.trim().length > 0\n}","tryCatchPattern":"const res = await executeChatboxCliCommand({ argv: ['chats','search', query] }, ctx)\nif (!res.ok && res.kind === 'usage') {\n  // query missing/blank: prompt the user for a search term\n}","preventionTips":["Always pass a trimmed, non-empty positional query.","Prefer structured argv over a tokenized command string.","Validate in the caller and prompt the user before dispatching if blank."],"tags":["chatbox-cli","usage","validation","chats"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}