davila7/claude-code-templates · warning

Warning: Could not extract project from conversation ${fileP

Error message

Warning: Could not extract project from conversation ${filePath}:

What it means

extractProjectFromConversation could not read or scan the conversation file in its outer catch (distinct from per-line parse errors which are skipped). It returns 'Unknown' as the project name.

Source

Thrown at cli-tool/src/analytics/core/ConversationAnalyzer.js:516

          const item = JSON.parse(line);
          
          // Look for cwd field in the message
          if (item.cwd) {
            const projectName = path.basename(item.cwd);
            return projectName;
          }
          
          // Also check if it's in nested objects
          if (item.message && item.message.cwd) {
            return path.basename(item.message.cwd);
          }
        } catch (parseError) {
          // Skip invalid JSON lines
          continue;
        }
      }
    } catch (error) {
      console.warn(chalk.yellow(`Warning: Could not extract project from conversation ${filePath}:`, error.message));
    }
    
    return 'Unknown';
  }

  /**
   * Extract tool usage statistics from parsed messages
   * @param {Array} parsedMessages - Array of parsed message objects
   * @returns {Object} Tool usage statistics
   */
  extractToolUsage(parsedMessages) {
    const toolStats = {};
    const toolTimeline = [];
    let totalToolCalls = 0;

    parsedMessages.forEach(message => {
      if (message.role === 'assistant' && message.content) {
        const content = message.content;

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Verify the file from the warning still exists and is readable
  2. Re-run the analytics scan (transient deletion races resolve)
  3. If persistent, fix ownership: sudo chown -R $USER ~/.claude/projects
  4. Accept 'Unknown' project label if the file is intentionally gone
Defensive patterns

Strategy: try-catch

Validate before calling

const st = await fs.stat(filePath).catch(() => null);
if (!st?.isFile()) return 'Unknown';

Try / catch

try { /* scan conversation */ }
catch (error) { console.warn(`Could not extract project from ${filePath}:`, error.message); return 'Unknown'; }

Prevention

When it happens

Trigger: The conversation file path is unreadable (EACCES/ENOENT after listing, file deleted between readdir and read), or content handling throws for a non-line-based reason.

Common situations: Files deleted by retention/cleanup scripts while the analyzer is scanning; permission changes mid-scan; very large files causing read errors.

Related errors


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