davila7/claude-code-templates · warning

Conversation not found

Error message

Conversation not found

What it means

404 from POST /api/conversations/:id/search: no conversation in this.data.conversations has an id equal to the :id path parameter. Intentional validation, not a crash.

Source

Thrown at cli-tool/src/chats-mobile.js:319

            contentSearch
          },
          timestamp: new Date().toISOString()
        });
      } catch (error) {
        console.error('Error searching conversations:', error);
        res.status(500).json({ error: 'Internal server error', message: error.message });
      }
    });

    // API to search within a specific conversation
    this.app.post('/api/conversations/:id/search', async (req, res) => {
      try {
        const conversationId = req.params.id;
        const { query } = req.body;
        const conversation = this.data.conversations.find(conv => conv.id === conversationId);

        if (!conversation) {
          return res.status(404).json({ error: 'Conversation not found' });
        }

        if (!query || !query.trim()) {
          return res.json({
            matches: [],
            totalMatches: 0,
            conversationId: conversationId
          });
        }

        // Get all messages from the conversation
        const allMessages = await this.conversationAnalyzer.getParsedConversation(conversation.filePath);
        const searchTerm = query.toLowerCase();
        const matches = [];

        // Search through all messages
        allMessages.forEach((msg, index) => {
          let messageText = '';

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Refetch GET /api/conversations and use a current id
  2. Verify the session file still exists under ~/.claude/projects
  3. If the conversation should exist, restart the chats server to force a rescan
  4. Check the id for copy/paste errors (ids are typically session UUIDs/filenames)

Example fix

// before
await fetch(`/api/conversations/${id}/search`, ...);
// after
const conv = (await fetch('/api/conversations').then(r=>r.json())).conversations.find(c=>c.id===id);
if (!conv) throw new Error('stale id — refetch conversation list');
await fetch(`/api/conversations/${id}/search`, ...);
Defensive patterns

Strategy: type-guard

Validate before calling

const convs = await fetch(base + '/api/conversations').then(r => r.json());
const exists = convs.conversations.some(c => c.id === id);

Type guard

const conversationExists = (list, id) => list.some(c => c?.id === id);

Try / catch

try { ... } catch (e) { if (e.response?.status === 404) { await refreshConversationList(); return skip(); } throw e; }

Prevention

When it happens

Trigger: Searching inside a conversation that was deleted on disk, using an id from a stale client cache after the server rescanned, or a typo'd id.

Common situations: Mobile/web client kept an old conversation list; the session file was removed or the server restarted with a narrower scan.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/72749a52c9ca9f46. Report an issue: GitHub.