{"record":{"id":"7d578bf7b1d683ed","repo":"chatboxai/chatbox","slug":"conversation-not-found-sessionid","errorCode":null,"errorMessage":"Conversation not found: ${sessionId}","messagePattern":"Conversation not found: (.+?)","errorType":"validation","errorClass":"ChatboxCliUsageError","httpStatus":null,"severity":"warning","filePath":"src/renderer/packages/chatbox-cli/chats.ts","lineNumber":106,"sourceCode":"              ...compactMessage(message),\n            })\n          }\n        }\n      })\n      return { scope: 'global', query, hits, limitReached: hits.length >= limit }\n    },\n  },\n  {\n    path: ['chats', 'read'],\n    description: 'Read compact user/assistant messages from one conversation without approval.',\n    usage: 'chatbox chats read <session-id> [--limit 20] [--cursor 0]',\n    async execute({ parsed }) {\n      const sessionId = parsed.positionals[0]\n      if (!sessionId) throw new ChatboxCliUsageError('Missing session id.')\n      const limit = integerFlag(parsed, 'limit', { defaultValue: 20, min: 1, max: 50 })\n      const cursor = integerFlag(parsed, 'cursor', { defaultValue: 0, min: 0, max: 10_000_000 })\n      const session = await chatStore.getSession(sessionId)\n      if (!session) throw new ChatboxCliUsageError(`Conversation not found: ${sessionId}`)\n\n      const messages = readableMessages(session)\n      const page = messages.slice(cursor, cursor + limit)\n      return {\n        scope: 'session',\n        session: { id: session.id, name: session.name, type: session.type ?? 'chat' },\n        messages: page.map(({ message, thread }) => compactMessage(message, thread)),\n        nextCursor: cursor + page.length < messages.length ? cursor + page.length : null,\n        total: messages.length,\n      }\n    },\n  },\n]\n","sourceCodeStart":88,"sourceCodeEnd":120,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/chatbox-cli/chats.ts#L88-L120","documentation":"ChatboxCliUsageError thrown by 'chats read' after chatStore.getSession(sessionId) returns a falsy value. Although classified as a usage error (kind:'usage'), it reflects a data-lookup miss: the supplied id does not match any persisted conversation.","triggerScenarios":"A session id that was deleted, never existed, is from another device/account, or is mistyped. Also possible after a store reset/migration that changed ids.","commonSituations":"Stale ids cached in a UI, cross-device sync where the conversation is absent locally, post-migration id format changes, or copy/paste typos.","solutions":["Re-fetch the id list via ['chats','list'] and use a current id.","Verify the id belongs to the active account/device before reading.","Handle the { ok:false, kind:'usage' } result by prompting the user to pick a valid conversation."],"exampleFix":"// before\nawait executeChatboxCliCommand({ argv: ['chats', 'read', staleId] }, ctx)\n\n// after\nconst res = await executeChatboxCliCommand({ argv: ['chats', 'read', id] }, ctx)\nif (!res.ok && res.kind === 'usage') {\n  const list = await executeChatboxCliCommand({ argv: ['chats', 'list'] }, ctx)\n  // surface list to the user and retry with a chosen id\n}","handlingStrategy":"validation","validationCode":"// Verify the id exists before issuing the read by listing first,\n// or simply handle the usage result and re-list.\nconst list = await executeChatboxCliCommand({ argv: ['chats','list'] }, ctx)\nconst known = new Set(list.items.map((s) => s.id))\nif (!known.has(sessionId)) {\n  return { error: 'Conversation not found locally', kind: 'usage' }\n}\nawait executeChatboxCliCommand({ argv: ['chats','read', sessionId] }, ctx)","typeGuard":null,"tryCatchPattern":"const res = await executeChatboxCliCommand({ argv: ['chats','read', id] }, ctx)\nif (!res.ok && res.kind === 'usage' && res.error.startsWith('Conversation not found')) {\n  // re-list and prompt the user to pick a current conversation\n}","preventionTips":["Do not cache session ids long-term; re-list when a lookup misses.","Confirm the id belongs to the active account/device before reading.","Handle the usage result by prompting for a fresh selection."],"tags":["chatbox-cli","usage","chats","data-not-found"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}